Home

Awesome

botkit-webex-samples

This project implements a Botkit + Webex Teams adapter bot, based on the DevNet botkit-template project, providing some additional interesting samples and examples:

Websockets vs. Webhooks

Most Botkit features can be implemented by using the Webex Teams JS SDK websockets functionality, which establishes a persistent connection to the Webex Teams cloud for outbound and inbound messages/events.

Webex Teams also supports traditional HTTP webhooks for messages/events, which requires that your bot be accessible via a publically reachable URL. A public URL is also needed if your bot will be serving any web pages/files, e.g. images associated with the cards and buttons feature or the health check URL.

How to run (local machine)

Assuming you plan to us ngrok to give your bot a publically available URL (optional, see above), you can run this template in a jiffy:

  1. Clone this repo:

    git clone https://github.com/CiscoDevNet/botkit-webex-samples.git
    
    cd botkit-webex-samples
    
  2. Install the Node.js dependencies:

    npm install
    
  3. Create a Webex Teams bot account at 'Webex for Developers', and note/save your bot's access token

  4. Launch Ngrok to expose port 3000 of your local machine to the internet:

    ngrok http 3000
    

    Note/save the 'Forwarding' HTTPS address that ngrok generates

  5. Rename the env.example file to .env, then edit to configure the settings and info for your bot. Individual features included in this project may need specific configurations in .env (see the comments at the top of each feature .js file for details.)

    Note: you can also specify any of these settings via environment variables (which will take precedent over any settings configured in the .env file)...often preferred in production environments

    To successfully run all of the sample features, you'll need to specify at minimum a WEBEX_ACCESS_TOKEN (Webex Teams bot access token), and either a PUBLIC_URL or enable WEBSOCKET_EVENTS.

    Note: If running on Glitch.me or Heroku (with Dyno Metadata enbaled), the PUBLIC_URL will be auto-configured

    Additional values in the .env file (like OWNER and CODE) are used to populate the healthcheck URL meta-data.

    Be sure to save the .env file!

  6. You're ready to run your bot:

    node bot.js
    

Quick start on Glitch.me

You bot is all set, responding in 1-1 and 'group' spaces, and sending a welcome message when added to a space!

You can verify the bot is up and running by browsing to its healthcheck URL (i.e. the app domain.)

Quick start on Heroku

You bot is all set, responding in 1-1 and 'group' spaces, and sending a welcome message when added to a space!

You can verify the bot is up and running by browsing to its healthcheck URL (i.e. the app domain.)