Skip to main content

Python package for a Webex Bot based on websockets.

Project description

Introduction

Pypi Build Status

Pipeline

Python package for a Webex Bot based on websockets.

  • Uses the websocket module to receive incoming messages, thus avoiding the need to have a public IP for incoming webhooks.
  • Uses the webexteamssdk package to send back replies from the bot.

This is licensed under the MIT license.

Features

  • Receive incoming messages without having to run ngrok or similar.
  • Send replies based on your defined 'commands'.

Getting started

  1. Install this module:

pip install webex_bot

  1. 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>
  1. Run the bot:
import os
from webex_bot.webex_bot import WebexBot

# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"))


def send_echo(message, teams_message):
    """
    Sample command function that just echos back the sent message
    :param message: message with command already stripped
    :param teams_message: teams_message object. Get more info about the message received from this. e.g.

        room_id = teams_message.roomId
        user_email = teams_message.personEmail
        raw_message = teams_message.text

    :return: a string. Or a List of strings. If you return a list of strings, each will be sent in
    an individual reply to the user.
    """
    return message


# Add new commands to the box.
bot.add_command("/echo", "Send me back the message I sent you as a demo.", send_echo)

bot.run()

See example.py

======= History

0.1.2 (2021-03-15)

  • First release on PyPI.

Project details


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.1.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

webex_bot-0.1.2-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file webex_bot-0.1.2.tar.gz.

File metadata

  • Download URL: webex_bot-0.1.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for webex_bot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e0dd22fc8c3818aeacd7a57c6e27b7976faeabfbbe6bc1eae874f6d78cb71119
MD5 c833d24939695d8bc9ef29e4e1f56fc6
BLAKE2b-256 c057f1bc523de5df45e20318cd8bc7d24214c12558269d07b0bd9a85e983b922

See more details on using hashes here.

File details

Details for the file webex_bot-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: webex_bot-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for webex_bot-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5067850d280360401f61630d1677c2337151e2ebc346451a21614393469b395c
MD5 d0d1a2be34bde073e46b197e4c2ecf84
BLAKE2b-256 e609e30dafb93ec3cd12138353e696e8cad9212abe0c0e8591104fe61f758a08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page