Home

Awesome

Spark Bot for CODEMOTION Rome 2017

QuizBot is a chatbot, built for Cisco Spark, that implements a "quiz" game. The bot asks the user a set of questions drawn randomly from a database. The user must select the correct answer among 4 possible answers (marked with A, B, C or D) within a time limit. Each correct answer is given an amount of points that is proportional to the remaining time. Wrong answers, as well as answers not given within the time limit, are given 0 points. <br>This bot has been used for a contest at the international tech conference Codemotion Rome 2017 (March 24-25th 2017). <br>The best scores were shown on a monitor. Here you can find the code used for the ranking page.

Installation

Application Server

Database connection

<subsystem xmlns="urn:jboss:domain:datasources:4.0">
	<datasources>
		<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
			<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
			<driver>h2</driver>
			<security>
				<user-name>sa</user-name>
				<password>sa</password>
			</security>
		</datasource>
		<datasource jta="true" jndi-name="java:jboss/datasources/quizdb" pool-name="quizdb" enabled="true" use-java-context="true">
			<connection-url>connection-url</connection-url>
			<driver>postgresql</driver>
			<security>
				<user-name>user-name</user-name>
				<password>password</password>
			</security>
		</datasource>
		<drivers>
			<driver name="h2" module="com.h2database.h2">
				<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
			</driver>
			<driver name="postgresql" module="org.postgresql">
				<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
			</driver>
		</drivers>
	</datasources>
</subsystem>

Deployment

After building sources, choose one of the following:

Commands

This is the list of commands that can be given to QuizBot through the Cisco Spark interface.

User commands

Admin commands (ChatOps)

All admin commands start with / and can be issued only by users with Admin role.

Business commands

All business commands start with / and can be issued only by users with Marketing role.

User roles

Users can be assigned both Admin and Marketing role. Maintainers of the bot should have both these roles. Roles can be assigned by filling table USER_ROLES:

<table> <h> <td>id</td> <td>user_id</td> <td>admin</td> <td>marketing</td> </h> <tr> <td>Sequence number for the row</td> <td>Id of the user (references <i>USERS</i> table)</td> <td>True/False</td> <td>True/False</td> </tr> </table>

Configuration variables

These configurations can be edited by updating the BOT_CONFIG table or by issuing command /setconf to the bot.

These configurations can be edited by updating the SPARK_CONFIG table.

Modules description

chatbot-clients-common

Contains common interfaces for different clients.

chatbot-clients-ciscospark

Web app that is responsible for the communication with Spark through the <a href="https://github.com/ciscospark/spark-java-sdk">Spark Java SDK</a>.

chatbot-clients-ciscospark-logic

Business logic for <a href="https://github.com/LucaCalabrese/codemotion-spark-bot#chatbot-clients-ciscospark">chatbot-clients-ciscospark</a>.

chatbot-codemotion

Web app that exposes REST APIs for the interaction with the bot.

chatbot-codemotion-logic

Contains the business logic of the bot (game management) and the interaction with the database.