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 asdocker
and have usedgit
to fork/clone this repo. - Copy
token.json
(file containing only the bot's token as a quoted string) into theconfig
folder. - Run
npm install
to populate thenode_modules
folder andnpm test
to exercise a simple test server. - Examine
package.json
to understand thescripts
you can run vianpm
. Feel free to add stuff here. - Next, try running
npm run docker
to 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 start
executes theserver
script by default? (a simple test server, not the bot) - Examine the contents of the
bot
folder and the provided script. Can you figure out ho? - Why isn't your bot responding to messages yet? Try
npm run tunnel
in 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.