Python package for a Webex Bot based on websockets.
Project description
Introduction
By using this module, you can create a Webex Teams messaging bot quickly in just a couple of lines of code.
This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or inside a LAN. This package instead uses a websocket to receive messages from the Webex cloud.
Features
- Uses the websockets module to receive incoming messages, thus avoiding the need to have a public IP or use incoming webhooks.
- Simply add 'commands' which are just strings which instruct the bot to perform some action and reply with some result.
- Allows for single or multi-post responses. This is useful if you want to reply with a lot of data, but it won't all fit in a single response.
- Restrict bot to certain users or domains.
- Uses the webexteamssdk package to send back replies from the bot.
Getting started
- Install this module from pypi:
pip install webex_bot
- On the Webex Developer portal, create a new bot token and expose it as an environment variable.
export WEBEX_TEAMS_ACCESS_TOKEN=<your bots token>
- Run your script:
python example.py
See example.py for details:
import os
from webex_bot.commands.agenda import AgendaCommand
from webex_bot.webex_bot import WebexBot
# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"))
# Add new commands for the bot to listen out for.
bot.add_command(AgendaCommand())
# Call `run` for the bot to wait for incoming messages.
bot.run()
- Now, just interact 1-1 with the bot. Send it a message with the text:
echo
or agenda
and off you go!
History
0.1.2 (2021-03-15)
- First release on PyPI.
0.1.4 (2021-03-23)
- Better retry on websocket connection failure
- Added support for approved domains
- Other cleanup
0.1.5 (2021-03-23)
- Retry websocket connection on socket.gaierror. (#1)
0.1.6 (2021-03-25)
- Send ack on websocket message received. (#2)
0.1.7 (2021-03-26)
- Minor cleanup.
- Log bot email on startup.
0.1.8 (2021-05-04)
- Fetch incoming message ID as base64.
0.2.0 (2021-05-07)
- Switch format entirely to use cards.
0.2.1 (2021-05-07)
- Import fix
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
webex_bot-0.2.1.tar.gz
(17.8 kB
view details)
Built Distribution
File details
Details for the file webex_bot-0.2.1.tar.gz
.
File metadata
- Download URL: webex_bot-0.2.1.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e85e5c919ee21aaa4c7815dc175d80a365e962ffcab3ca7c8dc4d1e938103df |
|
MD5 | 1aef82db609fdd1c68a5419e0262fd52 |
|
BLAKE2b-256 | c7a992c7f53f2b3f6d4b59e9089f210efbb0811e4c0c2d66afd76bdafecd5877 |
File details
Details for the file webex_bot-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: webex_bot-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e5bac618d69b7df1fe9974f3f95b8297304e185cc170f1eaff61cd15413ba7 |
|
MD5 | 88cc4744b607af5b308618e39fdeeab3 |
|
BLAKE2b-256 | 1094cb5b7751bdd832ba31e5250440a0931ca1331fc4c187dac2c30b2bd46e42 |