You: resourceful business collaboration dev/enabler; if you like this, you might also like cisco-webex-tools.
This bot is a template--it responds when DM'd. (ignores non-humans, can only respond in groups when @mentioned)
When triggered (by webhook delivery = POST to target URL) an event action is fired, passing relevant JSON data.
Events are handled without blocking other HTTP traffic (actions are processed asynchronously) to enable scale-up.
Upfront: we expect you have installed a modern NodeJS as well as functional docker and git commands.
To get started, create your bot here: https://developer.webex.com/add-app.html (other application types: out of scope)
Copy the (double quoted) token string to file named token.json e.g. "$SECRET_BOT_ACCESS_TOKEN_FROM_DEV_PORTAL"
Clone this repository with git and drop token.json into the config directory, then follow the instructions below.
Last week, we created a Cisco Webex Teams bot (application) using the dev portal. (developer.webex.com)
- You already have NodeJS (for
npm) as well asdockerand have usedgitto fork/clone this repo. - Copy
token.json(file containing only the bot's token as a quoted string) into theconfigfolder. - Run
npm installto populate thenode_modulesfolder andnpm testto exercise a simple test server. - Examine
package.jsonto understand thescriptsyou can run vianpm. Feel free to add stuff here. - Next, try running
npm run dockerto build and spawn a container using the includedDockerfile.
By default, docker will create a lightweight container running the start script. See Tooling Primer, below.
- Notice how
npm startexecutes theserverscript by default? (a simple test server, not the bot) - Examine the contents of the
botfolder and the provided script. Can you figure out ho? - Why isn't your bot responding to messages yet? Try
npm run tunnelin another terminal. - Can you modify your bot to reply with a different message, or do something else?
- What will you make your bot do? Will you add an API, or a React front-end?
Create an issue on GitHub (we also accept PRs) if you run into any problems. Your feedback is much appreciated!
Note: use Kinematic and/or Github Desktop if you prefer GUIs.
You might prefer an IDE, but NodeJS makes it simple enough to write JavaScript with any editor, even ones like vim.
To send HTTP requests, use your web browser (for simple GETs) or Postman or e.g. curl -v http://localhost:8080/.
From the command line, use docker ps -a to list all your local containers, then docker stop ... and docker rm ....
The included Dockerfile is simple enough for beginners, but robust enough for a (basic) production application.
If you add databases or other services, you might want to explore tools like e.g. docker-compose, Swarm, etc.