Webex-Teams-Interactive-Bot

Basic interactive bot for Webex Teams.

Webex Teams bots

Bots are similar to regular Webex Teams users. They can participate in 1-to-1 and group spaces and users can message them directly or add them to a group space. A special badge is added to a bot's avatar in the Webex Teams clients so users know they're interacting with a bot instead of a human.

A bot can only access messages sent to it directly. In group spaces, bots must be @mentioned to access the message. In 1-to-1 spaces, a bot has access to all messages from the user.

Bots do not, however, perform actions within Webex Teams on behalf of a Webex Teams user.

More information about bots

Getting started

Creating a Virtual env and install the required packages.

Run the commands below to create a virtual environment and activate it. Commands might slightly differ depending of your OS. Commands below are for Unix kernerls.

python -m venv venv
source ./venv/bin/activate

Then, install the required packages

pip install -r requirements.txt

ngrok

If you run the bot directly on your computer, you can use ngrok to make it publicly accessible via a public URL.

Sart ngrok on port 8080.

./ngrok http 8080

Launching the bot

Then, execute the ./core/main.py file.

Capabilities

Capabilities of the bot are listed in the ./core/bot_capabilities.py file.

Webhooks tools

Webex Teams webhooks

A webhook is an HTTP callback, or an HTTP POST, to a specified URL that notifies your app when a particular activity or “event” has occurred in one of your resources on the Webex Teams platform. The benefit of using webhooks is that they allow your application to receive real-time data from Webex Teams, so you can keep up with the state of your resources (i.e. rooms, messages, memberships, etc.).

More information about Webex Teams wehbooks

post_webhooks.py

Post Webhooks for when my bot is mentioned, and when my bot is added to a new room.

  • mentioned will be sent to {URL}/newmessage
  • mentioned will be sent to {URL}/newroom

Usage: python post_webhooks.py [-h] -t TOKEN -u URL

To avoid errors, if the URL giving as a parameter ends with a "/", removes it.

delete_webhooks.py

Deletes all active webhooks for a specific Webex Teams token.

Usage: delete_webhooks.py [-h] -t TOKEN

function.py

Set of functions used by the files in this folder.

Editing the variables

Don't forget to edit the ./core/variables.py file with your bot token.

Examples

Interfaces configuration data

Listing the interfaces with their configuration data.

Listing the capabilities

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.