Setting Up A Webex Bot

This post contains some rough notes on setting up a basic Webex bot.

Creating A Bot Account

The documentation for Webex bots is at Clicking the ‘Create Bot’ button you arrive at the following page (you will need to sign in/create an account).

Webex create bot page

Fill in this form and select ‘Add Bot’ at the bottom of the page. Take note of the bot access token (this allows you to control the bot’s actions - don’t commit to version control!).

Let’s next look into how to receive notifications for events (such as messages being sent to the bot).

Minimal Flask Server

Check out for setting up a webhook (i.e. subscribing to a certain type of notification). To do this you will need to provide a web address where you will be receiving POST requests (e.g. set up with AWS - this is out of scope of this post). For example, create a POST request to containing:

  "name": "New message received",
  "targetUrl": "",
  "resource": "messages",
  "event": "created"

Refer to and

You can then implement the server script to handle these POST requests at the given address. Using Flask (python library) this might look something like the following (see

from flask import Flask, request
import requests
from requests_toolbelt import MultipartEncoder

app = Flask(__name__)

ACCESS_TOKEN = "..."  # Fill in from bot create page

def handle_message():
    data = request.get_json()["data"]
    msg = "I'm *very* excited"
    multipart = MultipartEncoder(
        {"markdown": msg, "personId": data["personId"]}
    response =
            "Authorization": f"Bearer {ACCESS_TOKEN}",
            "Content-Type": multipart.content_type,

This should then be run on the server that can be located on the public internet by Webex at the address you provided (‘’ in the example webhook request above). It can be run as any Python script, although note the dependency on flask, requests and requests_toolkit!

See or for more complete examples.

Comments are currently closed