{"id":13764670,"url":"https://github.com/hpreston/myhero_spark","last_synced_at":"2025-10-05T12:47:09.249Z","repository":{"id":88422719,"uuid":"57000524","full_name":"hpreston/myhero_spark","owner":"hpreston","description":"Simple Cisco Spark Bot for the MyHero Demo","archived":false,"fork":false,"pushed_at":"2018-01-03T15:45:09.000Z","size":42,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T14:31:55.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/hpreston.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":"2016-04-25T00:16:51.000Z","updated_at":"2018-08-22T17:42:59.000Z","dependencies_parsed_at":"2024-01-30T06:59:09.241Z","dependency_job_id":"3488019c-d62a-4c7b-aee6-1925e0c49b19","html_url":"https://github.com/hpreston/myhero_spark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hpreston/myhero_spark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpreston%2Fmyhero_spark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpreston%2Fmyhero_spark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpreston%2Fmyhero_spark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpreston%2Fmyhero_spark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hpreston","download_url":"https://codeload.github.com/hpreston/myhero_spark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpreston%2Fmyhero_spark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278457484,"owners_count":25989955,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:25.189Z","updated_at":"2025-10-05T12:47:09.212Z","avatar_url":"https://github.com/hpreston.png","language":"Python","funding_links":[],"categories":["Code samples"],"sub_categories":["Bot samples"],"readme":"# MyHero Spark Bot\n\nThis is the a Spark Bot for a basic microservice demo application.\nThis provides an interactive chat service for a voting system where users can vote for their favorite movie superhero.\n\nDetails on deploying the entire demo to a Mantl cluster can be found at\n\n* MyHero Demo - [hpreston/myhero_demo](https://github.com/hpreston/myhero_demo)\n\nThe application was designed to provide a simple demo for Cisco Mantl.  It is written as a simple Python Flask application and deployed as a docker container.\n\n**NOTE: To leverage the Spark Bot Service, your Mantl Cluster MUST be configured for deployed applications to be accessible from the public Internet.  This is because it relies on the Spark Cloud to be able to send a WebHook to the myhero_spark application you run in Mantl***\n\nOther services are:\n\n* Data - [hpreston/myhero_data](https://github.com/hpreston/myhero_data)\n* App - [hpreston/myhero_app](https://github.com/hpreston/myhero_app)\n* Web - [hpreston/myhero_web](https://github.com/hpreston/myhero_web)\n* UI - [hpreston/myhero_ui](https://github.com/hpreston/myhero_ui)\n* Ernst - [hpreston/myhero_ernst](https://github.com/hpreston/myhero_ernst)\n  * Optional Service used along with an MQTT server when App is in \"queue\" mode\n* Spark Bot - [hpreston/myhero_spark](https://github.com/hpreston/myhero_spark)\n  * Optional Service that allows voting through IM/Chat with a Cisco Spark Bot\n* Tropo App - [hpreston/myhero_tropo](https://github.com/hpreston/myhero_tropo)\n  * Optional Service that allows voting through TXT/SMS messaging\n\n\nThe docker containers are available at\n\n* Data - [hpreston/myhero_data](https://hub.docker.com/r/hpreston/myhero_data)\n* App - [hpreston/myhero_app](https://hub.docker.com/r/hpreston/myhero_app)\n* Web - [hpreston/myhero_web](https://hub.docker.com/r/hpreston/myhero_web)\n* UI - [hpreston/myhero_ui](https://hub.docker.com/r/hpreston/myhero_ui)\n* Ernst - [hpreston/myhero_ernst](https://hub.docker.com/r/hpreston/myhero_ernst)\n  * Optional Service used along with an MQTT server when App is in \"queue\" mode\n* Spark Bot - [hpreston/myhero_spark](https://hub.docker.com/r/hpreston/myhero_spark)\n  * Optional Service that allows voting through IM/Chat with a Cisco Spark Bot\n* Tropo App - [hpreston/myhero_tropo](https://hub.docker.com/r/hpreston/myhero_tropo)\n  * Optional Service that allows voting through TXT/SMS messaging\n\n# Spark Developer Account Requirement\n\nIn order to use this service, you will need a Cisco Spark Account to use for the bot.  The bot is built for ease of use, meaning any message to the account used to create the Bot will be acted on and replied to.  This means you'll need to create a new Spark account for the demo.  \n\nCreating an account is free and only requires a working email account (each Spark Account needs a unique email address).  Visit [http://www.ciscospark.com](http://www.ciscospark.com) to signup for an account.\n\nDeveloper access to Spark is also free and information is available at [http://developer.ciscospark.com](http://developer.ciscospark.com).\n\nIn order to access the APIs of Spark, this bot needs the Developer Token for your account.  To find it:\n\n* Go to [http://developer.ciscospark.com](http://developer.ciscospark.com) and login with the credentials for your account.\n* In the upper right corner click on your picture and click `Copy` to copy your Access Token to your clipboard\n* Make a note of this someplace for when you need it later in the setup\n  * **If you save this in a file, such as in the `Vagrantfile` you create later, be sure not to commit this file.  Otherwise your credentials will be availabe to anyone who might look at your code later on GitHub.**\n\n## Basic Application Details\n\nRequired\n\n* flask\n* ArgumentParser\n* requests\n\n# Environment Installation\n\n    pip install -r requirements.txt\n\n# Basic Usage\n\nIn order to run, the service needs several pieces of information to be provided:\n\n* App Server Address\n* App Server Authentication Key to Use\n* Spark Bot Authentication Key to Require in API Calls\n* Spark Bot URL\n* Spark Account Details\n  * Spark Account Email\n  * Spark Account Token\n\nThese details can be provided in one of three ways.\n\n* As a command line argument\n\n\t```\n\tpython myhero_spark/myhero_spark.py \\\n\t  --app \"http://myhero-app.server.com\" \\\n\t  --appkey \"APP AUTH KEY\" \\\n\t  --secret \"BOT AUTH KEY\" \\\n\t  --boturl \"http://myhero-spark.server.com\" \\\n\t  --botemail \"myhero.demo@server.com\" \\\n\t  --token \"HAAKJ1231KFSDFKJSDF1232132\"\n\t```\n  \n* As environment variables\n\n\t```\n\texport myhero_app_server=http://myhero-app.server.com`\n\texport myhero_app_key=APP AUTH KEY`\n\texport myhero_spark_bot_email=myhero.demo@server.com`\n\texport spark_token=HAAKJ1231KFSDFKJSDF1232132`\n\texport myhero_spark_bot_url=http://myhero-spark.server.com`\n\texport myhero_spark_bot_secret=\"BOT AUTH KEY\"`\n\tpython myhero_spark/myhero_spark.py`\n\t```\n\n* As raw input when the application is run\n\n\t```\n\tpython myhero_app/myhero_app.py`\n\tWhat is the app server address? http://myhero-app.server.com`\n\tApp Server Key: APP AUTH KEY`\n\t .\n\t .\n\t\n\t```\n\nA command line argument overrides an environment variable, and raw input is only used if neither of the other two options provide needed details.\n\n# Accessing\n\nUpon startup, the service registers a webhook to send all new messages to the service address.\n\n\n## Interacting with the Spark Bot\nThe Spark Bot is a very simple interface that is designed to make it intuitive to use.  Simply send any message to the Spark Bot Email Address to have the bot reply back with some instructions on how to access the features.\n\nThe bot is deisgned to look for commands to act on, and provide the basic help message for anything else.  The commands are:\n\n* /options\n  * return a list of the current available options to vote on\n* /results\n  * list the current status of voting results\n* /vote {{ option }} \n  * Place a vote for the 'option'\n* /help \n  * Provide a help message\n\n## REST APIs\n\n# /\n\nThe main service API is at the root of the applciation and is what is used for the Spark Webhooks.\n\n# /hello/:email \n\nThere is an API call that can be leveraged to have the Spark Bot initiate a chat session with a user.  This API responds to GET requests and then will send a Spark message to the email provided.  \n\nExample usage\n\n```\ncurl http://myhero-spark.domain.local/hello/user@email.com \n```\n\n# /health \n\nThis is an API call that can be used to test if the Spark Bot service is functioning properly.\n  \n```\ncurl -v http://myhero-spark.domain.local/health \n\n*   Trying...\n* Connected to myhero-spark.domain.local (x.x.x.x)\n\u003e GET /health HTTP/1.1\n\u003e Host: myhero-spark.domain.local\n\u003e User-Agent: curl/7.43.0\n\u003e Accept: */*\n\u003e \n* HTTP 1.0, assume close after body\n\u003c HTTP/1.0 200 OK\n\u003c Connection: close\n\u003c \n* Closing connection 0\nService up. \n```\n\n# Local Development with Vagrant\n\nI've included the configuration files needed to do local development with Vagrant in the repo.  Vagrant will still use Docker for local development and requires the following be installed on your laptop: \n\n* [Vagrant 2.0.1 or higher](https://www.vagrantup.com/downloads.html)\n* [Docker](https://www.docker.com/community-edition)\n\nBefore running `vagrant up` you will need to finish the Vagrant file configuration by adding the Spark Account Email and Token to the environment variables used by the container.  To do this:\n\n* Make a copy of Vagrantfile.sample to use\n  * `cp Vagrantfile.sample Vagrantfile`\n* Edit `Vagrantfile` and add your details where indicated\n  * `vim Vagrantfile`\n  * Change the value for `myherospark_bot_email` and `spark_token` in the `docker.env` hash\n\nTo start local development run:\n* `vagrant up`\n* Now you can interact with the API or interface at localhost:15001 (configured in Vagrantfile)\n  - example:  from your local machine `curl -H \"key: DevBot\" http://localhost:15003/demoroom/members`\n  - Environment Variables are configured in Vagrantfile for development\n\nEach of the services in the application (i.e. myhero_web, myhero_app, and myhero_data) include Vagrant support to allow working locally on all three simultaneously.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpreston%2Fmyhero_spark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhpreston%2Fmyhero_spark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpreston%2Fmyhero_spark/lists"}