A Python application to automatically deploy a Webex Bot to Heroku using the Heroku Platform APIs.
Webex Bots: Webex is Cisco's cloud collaboration platform and the Cisco Webex for Developers program opens up the platform to extend and customize the Webex experience. Bots are one example that can help users automate tasks, add external content, and gain efficiencies. There are different types of bots:
Heroku: Heroku is a platform as a service (Paas), which is popular by developers to deploy and manage applications in the cloud. It officially supports languages such as Python, Node.js, or Java, and it provides an API to automate services, which makes it easy to use and quick to setup.
Webex Bot on Heroku: Webex bots are triggered using webhooks. Webhooks need to be configured to listen to a public URL, which is provided when hosting the application on a cloud service like Heroku. Heroku hosts the application and makes it publicly accessible at the URL it is hosted at, so that when a service is configured to send a message to the webhook, the application listens and responds. The application processes the request following the script that defines the actions of the bot and sends a notification in the name of the bot.
External Services and Webhooks: Examples of external services that can be configured to send messages or alerts to a webhook include Cisco solutions, such as Meraki or DNA, but also other services like Grafana. To deploy a controller bot in Webex, a webhook must be configured to respond to events within Webex, such as someone sending a message to the bot or adding the bot to a team space.
Webex Account: If you do not have a Webex account yet, you can create one here for free.
Bot:
Heroku:
app.json
file following the official schema.Clone this repository with git clone <this repo>
.
Navigate to the bot
directory and open the bot.py
file. Take the following actions:
Create your own repository on GitHub and push all files in the bot
directory (app.json
, bot.py
, Procfile
, requirements.txt
) to the repository following these steps.
Navigate to the setup
directory and open the credentials.yaml
file. Fill in the information and save the file:
heroku_username: '' # your Heroku account username
heroku_password: '' # your Heroku account paswoord
heroku_region: '' # either 'eu' or 'us'
webex_bot_token: '' # the access token noted during bot creation
webex_bot_email: '' # for controller bots (see Prerequisites section), leave empty for notifier bots
webex_room_id: '' # for notifier bots (see Prerequisites section), leave empty for controller bots
github_url: '' # the URL of the GitHub repository created in step 3 of the installation*
github_version: '' # the version of the GitHub repository to be deployed, can be a branch name (e.g. master) or commit hash
NB: The GitHub URL is used to create the source_blob
that is required to setup an app using the Heroku Platform APIs. For that matter, the repository must be public. If the repository is private, you will need to include a username and token according to the information provided here.
(Optional) Create a Python virtual environment and activate it (find instructions here).
In a terminal, navigate to the setup
directory, and install the dependencies with pip install -r requirements_setup.txt
.
Run the setup script with python setup.py
.
From the logging output written to the console while the script is running, note the URL the app is deployed. It has the following format: https://app-name.herokuapp.com.
bot.py
script.bot.py
script.
@mentioned
to access the message. In 1-to-1 spaces, a bot has access to all messages from the user.Provided under Cisco Sample Code License, for details see LICENSE.
Our code of conduct is available here.
See our contributing guidelines here.
Owner
Contributors
Categories
Products
Catalyst CenterWebexMerakiProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community