{"id":13764577,"url":"https://github.com/LucaCalabrese/codemotion-spark-bot","last_synced_at":"2025-05-10T19:31:36.641Z","repository":{"id":89281339,"uuid":"83782878","full_name":"LucaCalabrese/codemotion-spark-bot","owner":"LucaCalabrese","description":"Spark Bot for Codemotion Rome 2017","archived":false,"fork":false,"pushed_at":"2017-05-30T12:39:18.000Z","size":11758,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T16:08:25.460Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucaCalabrese.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-03-03T09:43:30.000Z","updated_at":"2021-06-04T10:49:18.000Z","dependencies_parsed_at":"2023-04-13T04:22:24.885Z","dependency_job_id":null,"html_url":"https://github.com/LucaCalabrese/codemotion-spark-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCalabrese%2Fcodemotion-spark-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCalabrese%2Fcodemotion-spark-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCalabrese%2Fcodemotion-spark-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCalabrese%2Fcodemotion-spark-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaCalabrese","download_url":"https://codeload.github.com/LucaCalabrese/codemotion-spark-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224986053,"owners_count":17402936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:00:23.157Z","updated_at":"2024-11-17T00:30:55.260Z","avatar_url":"https://github.com/LucaCalabrese.png","language":"Java","funding_links":[],"categories":["Code samples"],"sub_categories":["Bot samples"],"readme":"Spark Bot for CODEMOTION Rome 2017\n====================================\n\n**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.\n\u003cbr\u003eThis bot has been used for a contest at the international tech conference Codemotion Rome 2017 (March 24-25th 2017).\n\u003cbr\u003eThe best scores were shown on a monitor. [Here](https://github.com/LucaCalabrese/codemotion-spark-bot-scores) you can find the code used for the ranking page.\n\nInstallation\n------------\n### Application Server\n* Download and install \u003ca href=\"http://wildfly.org/downloads/\"\u003eWildfly 10.1.0.Final\u003c/a\u003e\n\n### Database connection\n* Download and install \u003ca href=\"https://www.postgresql.org/download/\"\u003ePostgreSQL 9.6\u003c/a\u003e.\n* Create a new database (through PGAdmin or CLI).\n* Run script quizdb.sql (in *setup* folder) to create all the tables.\n* Download \u003ca href=\"https://jdbc.postgresql.org/download.html\"\u003ePostgreSQL JDBC driver\u003c/a\u003e (v 9.4.1212).\n* Copy postgresql-9.4.1212.jar into folder *WILDFLY_HOME/modules/system/layers/base/org/postgresql/main*, where *WILDFLY_HOME* is the path of the Wildfly root directory.\n* In the above folder insert *module.xml*.\n* Make a backup copy of file *WILDFLY_HOME/standalone/configuration/standalone.xml*\n* Copy the provided *standalone.xml* into folder *WILDFLY_HOME/standalone/configuration*\n* Open the new *standalone.xml* and reach the following lines:\n```xml\n\u003csubsystem xmlns=\"urn:jboss:domain:datasources:4.0\"\u003e\n\t\u003cdatasources\u003e\n\t\t\u003cdatasource jndi-name=\"java:jboss/datasources/ExampleDS\" pool-name=\"ExampleDS\" enabled=\"true\" use-java-context=\"true\"\u003e\n\t\t\t\u003cconnection-url\u003ejdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE\u003c/connection-url\u003e\n\t\t\t\u003cdriver\u003eh2\u003c/driver\u003e\n\t\t\t\u003csecurity\u003e\n\t\t\t\t\u003cuser-name\u003esa\u003c/user-name\u003e\n\t\t\t\t\u003cpassword\u003esa\u003c/password\u003e\n\t\t\t\u003c/security\u003e\n\t\t\u003c/datasource\u003e\n\t\t\u003cdatasource jta=\"true\" jndi-name=\"java:jboss/datasources/quizdb\" pool-name=\"quizdb\" enabled=\"true\" use-java-context=\"true\"\u003e\n\t\t\t\u003cconnection-url\u003econnection-url\u003c/connection-url\u003e\n\t\t\t\u003cdriver\u003epostgresql\u003c/driver\u003e\n\t\t\t\u003csecurity\u003e\n\t\t\t\t\u003cuser-name\u003euser-name\u003c/user-name\u003e\n\t\t\t\t\u003cpassword\u003epassword\u003c/password\u003e\n\t\t\t\u003c/security\u003e\n\t\t\u003c/datasource\u003e\n\t\t\u003cdrivers\u003e\n\t\t\t\u003cdriver name=\"h2\" module=\"com.h2database.h2\"\u003e\n\t\t\t\t\u003cxa-datasource-class\u003eorg.h2.jdbcx.JdbcDataSource\u003c/xa-datasource-class\u003e\n\t\t\t\u003c/driver\u003e\n\t\t\t\u003cdriver name=\"postgresql\" module=\"org.postgresql\"\u003e\n\t\t\t\t\u003cxa-datasource-class\u003eorg.postgresql.xa.PGXADataSource\u003c/xa-datasource-class\u003e\n\t\t\t\u003c/driver\u003e\n\t\t\u003c/drivers\u003e\n\t\u003c/datasources\u003e\n\u003c/subsystem\u003e\n```\n* Substitute:\n  * *connection-url* with the url of your database (e.g. *jdbc:postgresql://example.com/quizdb*)\n  * *user-name* and *password* with the credentials used when accessing your database\n* Connect to the database and change the [configurations](#configuration-variables) according to your environment.\n\n### Deployment\nAfter building sources, choose one of the following:\n* Deploy both .war files (*chatbot-clients-ciscospark.war* and *chatbot-codemotion.war*) through the Administration Console of Wildfly.\n* Copy both .war files in folder WILDFLY_HOME/standalone/deployments.\n\nCommands\n--------\nThis is the list of commands that can be given to **QuizBot** through the Cisco Spark interface.\n\n### User commands\n\n* **play**: Starts the game or goes to the next question if the game has already started.\n* **next**: Same as \u003cb\u003eplay\u003c/b\u003e.\n* **a / b / c / d**: Used to select an answer when prompted by the bot.\n* **score**: Prints the current score for the user.\n* **phone**: Allows to edit the user's contact phone number\n* **now**: Shows the list of upcoming events.\n* **help**: Shows the list of user commands in every step of the game.\n\n### Admin commands (ChatOps)\nAll admin commands start with **/** and can be issued only by users with Admin role.\n* **/clean [user's Spark email]**: Deletes all user data from the database, allowing him/her to play again (useful for testing).\n* **/clearcache**: Forces the application to reload the configuration settings from the database.\n* **/setconf [key] [value]**: Edits a configuration value.\n\n### Business commands\nAll business commands start with **/** and can be issued only by users with Marketing role.\n* **/winners**: Shows the top 3 scorers. Useful for winners extraction at the end of the contest.\n* **/stats**: Shows the total number of people registered to the contest.\n\nUser roles\n----------\n\n* **Admin**: Users allowed to use admin commands.\n* **Marketing**: Users allowed to use business commands.\n* **Normal user**: Every user that is not included in the roles above.\n\nUsers can be assigned both Admin and Marketing role. Maintainers of the bot should have both these roles.\nRoles can be assigned by filling table *USER_ROLES*:\n\n\u003ctable\u003e\n\u003ch\u003e\n\u003ctd\u003eid\u003c/td\u003e\n\u003ctd\u003euser_id\u003c/td\u003e\n\u003ctd\u003eadmin\u003c/td\u003e\n\u003ctd\u003emarketing\u003c/td\u003e\n\u003c/h\u003e\n\u003ctr\u003e\n\u003ctd\u003eSequence number for the row\u003c/td\u003e\n\u003ctd\u003eId of the user (references \u003ci\u003eUSERS\u003c/i\u003e table)\u003c/td\u003e\n\u003ctd\u003eTrue/False\u003c/td\u003e\n\u003ctd\u003eTrue/False\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nConfiguration variables\n-----------------------\n\nThese configurations can be edited by updating the *BOT_CONFIG* table or by issuing command **/setconf** to the bot. \n* **CONTEST_FINISHED_MSG**: Text message shown at the end of the contest.\n* **CTA_END_MSG**: Text message shown at the end of the game.\n* **CTA_MIDDLE_MSG**: Text message shown after question **CTA_QUESTION_NR**.\n* **CTA_MIDDLE_VALIDITY_DATE**: Date after which **CTA_MIDDLE_MSG** stops being shown (milliseconds since Jan 01 1970).\n* **CTA_QUESTION_NR**: Question after which the **CTA_MIDDLE_MSG** is shown.\n* **CTA_START_MSG**: Text message shown at the beginning of the game.\n* **DISCLAIMER**: Disclaimer text being shown when the user is prompted to insert his/her phone number.\n* **EVENTS_URL**: Url to get the list of upcoming events at the conference. \n* **GAME_ACTIVE**: When the game is not active, users cannot play (true / false).\n* **GAME_COMPLETED**: Message to show when the user has already completed the game (e.g.: \"You have already completed the game!\").\n* **HELP_MSG**: Help message, shown with **/help** command.\n* **MAP_CAPTION**: Caption for the image shown at the end of the game.\n* **MAP_URL**: URL for the image shown at the end of the game.\n* **NUMBER_OF_STAGES**: Unused, set to 1.\n* **QUESTIONS_PER_STAGE**: Number of questions in a stage, i.e. the total number of questions.\n* **QUESTION_TIMEOUT**: Timeout for the questions (in ms).\n* **SPARK_CONTEXT_ROOT**: Context root of chatbot-clients-ciscospark application (/client).\n* **SPARK_HOST**: Host of chatbot-clients-ciscospark application (e.g. the AWS EC2 host).\n* **SPARK_PORT**: Port of chatbot-clients-ciscospark application (e.g. 8080).\n* **WELCOME_MSG**: Welcome message shown when the bot is added to a room or in a 1-1 conversation.\n\nThese configurations can be edited by updating the *SPARK_CONFIG* table.\n* **BOT_CONTEXT_ROOT**: Context root of chatbot-clients-ciscospark application (/chatbot-codemotion).\n* **BOT_HOST**: Host of chatbot-codemotion application (e.g. the AWS EC2 host).\n* **BOT_PORT**: Port of chatbot-codemotion application (e.g. 8080).\n* **SPARK_BOT_TOKEN**: Spark token of the bot. Refer to [Spark for Devs site](https://developer.ciscospark.com/add-bot.html) for the creation of a Spark bot.\n\nModules description\n-------------------\n\n### chatbot-clients-common\nContains common interfaces for different clients.\n\n### chatbot-clients-ciscospark\nWeb app that is responsible for the communication with Spark through the \u003ca href=\"https://github.com/ciscospark/spark-java-sdk\"\u003eSpark Java SDK\u003c/a\u003e.\n\n### chatbot-clients-ciscospark-logic\nBusiness logic for \u003ca href=\"https://github.com/LucaCalabrese/codemotion-spark-bot#chatbot-clients-ciscospark\"\u003echatbot-clients-ciscospark\u003c/a\u003e.\n\n### chatbot-codemotion\nWeb app that exposes REST APIs for the interaction with the bot.\n\n### chatbot-codemotion-logic\nContains the business logic of the bot (game management) and the interaction with the database.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucaCalabrese%2Fcodemotion-spark-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLucaCalabrese%2Fcodemotion-spark-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucaCalabrese%2Fcodemotion-spark-bot/lists"}