![]() So, for example, if you wish for the bot to monitor any changes to a room's membership list, you would instanciate the bot like this: # Create a Bot Object bot = TeamsBot ( bot_app_name, teams_bot_token = teams_token, teams_bot_url = bot_url, teams_bot_email = bot_email, webhook_resource = "memberships", webhook_event = "all", ) This behavior can be changed using the "webhook_resource" and "webhook_event" parameters. Working with events other than created messagesīy default, the bot will configure the webhook to listen for messages:created events. set_help_message ( "Welcome to the Super Cool Bot! You can use the following commands: \n " ) You can do that with the "set_help_message" command like this:īot. Although "set_greeting" has existed for a while now, you may mostly like the internal greeting mechanism, but only want to change the help banner itself.run ( host = "0.0.0.0", port = 5000 )Ī sample script that shows more advanced bot features and customization is also provided in the repo.Īdvanced Options Changing the Help Message add_command ( "/dosomething", "help for do something", do_something ) if _name_ = "_main_" : # Run Bot bot. :param incoming_msg: The incoming message object from Teams :return: A text or markdown based reply """ return "i did what you said - ". getenv ( "TEAMS_BOT_APP_NAME" ) # Create a Bot Object bot = TeamsBot ( bot_app_name, teams_bot_token = teams_token, teams_bot_url = bot_url, teams_bot_email = bot_email, ) # A simple command that returns a basic string that will be sent as a reply def do_something ( incoming_msg ): """ Sample function to do some action. getenv ( "TEAMS_BOT_URL" ) bot_app_name = os. getenv ( "TEAMS_BOT_TOKEN" ) bot_url = os. getenv ( "TEAMS_BOT_EMAIL" ) teams_token = os. import os from webexteamsbot import TeamsBot # Retrieve required details from environment variables bot_email = os. export TEAMS_BOT_URL=Ī basic bot requires very little code to get going. Note: See ngrok for details on setting up an easy HTTP tunnel for development. The easiest way to use this module is to set a few environment variables Python 2.7 should also work.Ĭreate a virtualenv and install the module python3.6 -m venv venv On the Congratulations screen, make sure to copy the Bot's Access Token, you will need this in a second. You'll need to set a name, username, icon (either upload one or choose a sample), and provide a description. ![]() You'll need to start by adding your bot to the Webex Teams website.įill out all the details about your bot. If you don't already have a Webex Teams account, go ahead and register for one. If you've used ciscosparkbot you will find this package very similar and familiar. This version will both move to new Webex Teams branding as well as add new functionality. This package is based on the previous ciscosparkbot project. This package makes creating Webex Teams bots in Python super simple.
0 Comments
Leave a Reply. |