This community project driven regroups:
- Webex Teams bot samples built with Howdy's Botkit
- A template to quickly bootstrap your Botkit / Webex Teams bot project (updated for Botkit 4.5)
- An experimental websocket usage example
We suggest you start with the HelloWorld bot sample below.
New to Botkit?
- Read the "Botkit guide"
- Take the "Create Conversational Bots with Botkit" learning lab
New to Webex Teams?
- Go straight to Webex for Developers, sign in and click My apps to create a Webex Teams bot account
Simplest bot you can code: echo a message plus the Webex Teams user name that mentioned the bot:
And don't forget to @mention
the bot in group spaces:
Note that the bot will respond to anyone mentioning it, which means it can chat with other bots!
Assuming your bot is accessible from the internet or you exposed it via a tunneling tool such as ngrok, you can run any sample in a jiffy:
ngrok helps you expose the bot running on your laptop to the internet, type: ngrok http 8080
to launch
From a Mac/Linux terminal window, type:
git clone https://github.com/CiscoDevNet/botkit-webex-samples
cd botkit-webex-samples
npm install
ACCESS_TOKEN=0123456789abcdef PUBLIC_URL=https://abcdef.ngrok.io node helloworld.js
From a Windows CMD shell, type:
git clone https://github.com/CiscoDevNet/botkit-webex-samples
cd botkit-webex-samples
npm install
set ACCESS_TOKEN=0123456789abcdef
set PUBLIC_URL=https://abcdef.ngrok.io
set SECRET=not that secret
node helloworld.js
where:
- ACCESS_TOKEN is the API access token of your Webex Teams bot
- PUBLIC_URL is the root URL at which the Webex Cloud platform can reach your bot
The template regroups a set of best practices:
- configuration: pass settings either through environment variables on the command line, or by hardcoding some of them in the
.env
file. Note that env variable are priorized over theenv
file if values are found in both places. - healthcheck: check if everything is going well by hitting the
ping
endpoint exposed automatically. - skills: organize your bot behaviours by placing 'hear commands', 'convos' and 'events' in the skills directory. The bot comes with a ".commons", "help", "fallback" and "welcome" skills.
A conversational bot that illustrates Botkit conversation system through examples. The bot is built with the template provided in this repo.
You can test the bot live by inviting convos@sparkbot.io
to a Webex Teams's space.
This bot illustrates how you can create conversations, and uses a wrapper to an external API hosted on Heroku that lists current and upcoming events at DevNet.
This bot turns emoji tags to unicode characters and posts back the 'emojified' phrase
The bot leverages the experimental websocket library for Webex Teams, so that you don't need to register a Webhook and expose your bot on the internet.
From a Mac/Linux bash shell, type:
> npm install
> ACCESS_TOKEN=0123456789abcdef node emoji.js
From a Windows shell, type:
> npm install
> set ACCESS_TOKEN=0123456789abcdef
> node emoji.js