Package: webexbotsdk
webex bot creation framework and tools viapip install webexbotsdkwebexbotsdkteamsutiltinydbContributingwebexbotsdk.teams#EG|#API| A framework for creating a Webex Teams bot with automatic ngrok setup^EGconfigure withconfig.json{"botAccessToken":"",// (required) create a bot at https://developer.webex.com/my-apps"port":8080,// local server port"botName":"",// give it a unique identifier (ex. mybot)"encryptDb":false,// encrypts local json db"botDbKey":"",// key used when 'encryptDb' is true"ngrokAuthToken":"",// not recommended unless using a paid tier"disableDb":false// disable tinydb}quick startfromwebexbotsdk.teamsimportBotbot=Bot()@bot.hears(r'hi|hello')defhears_hi(message,data):person=bot.api.people.get(message.personId)returnbot.api.messages.create(roomId=message.roomId,text=f"Hi{person.displayName}")bot.setup('config.json')bot.run()with class inheritencefromwebexbotsdk.teamsimportBot,sdkclassHiBot(Bot):defsay_hi(self,replyTo:sdk.Message)->sdk.Message:person:sdk.Person=self.api.people.get(replyTo.personId)returnself.api.messages.create(roomId=replyTo.roomId,text=f"Hi{person.displayName}")hibot=HiBot()@hibot.hears(r'hi|hello')defhears_hi(message:sdk.Message,data):hibot.say_hi(message)hibot.setup('config.json')hibot.run()webexteamssdkis includedfromwebexbotsdk.teamsimportBotbot=Bot()all_rooms=bot.api.rooms.list()demo_rooms=[roomforroominall_roomsif'webexteamssdk Demo'inroom.title]local DB withTinyDBto remember things even after the bot is restartedfromwebexbotsdk.teamsimportBotfromwebexbotsdk.tinydbimportwherebot=Bot()@bot.hears(r'remember (\d+)')defhears_remember(message,data):number=int(data['groups'][0][0])bot.db.table('stuff').upsert({'personId':message.personId,'number':number},(where('personId')==message.personId)&(where('number')==number))@bot.hears('recall')defhears_recall(message,data):docs=bot.db.table('stuff').search(where('personId')==message.personId)bot.api.messages.create(roomId=message.roomId,text=f"I remember{', '.join([str(doc['number'])fordocindocs])}"iflen(docs)>0else'No numbers stored yet')bot.setup('config.json')bot.run()use dataclasses to type check DB documentsfromwebexbotsdk.teamsimportBotfromwebexbotsdk.tinydbimportwhere,dataclass,BotDocbot=Bot()@dataclassclassNumber(BotDoc):personId:strnumber:intdoc_id=bot.db.table('stuff').insert(Number(personId='asdf',number=14).dict())docs=[Number(**doc)fordocinbot.db.table('stuff').get(doc_id=doc_id)]bot.setup('config.json')bot.run()^APIclass BotpropsappBottlelocal server for teams webhooksapiWebexTeamsAPIwill be abbreviated asteamsin this docdbTinyDBlogpython 3Loggermethodssetup(config:dict)setup(path:str)configure Bot using a python dict or a filepath to a json configtable(name:str)->TinyDB.Tableretrievetinydb tablerun()start the bot local serversend_card(roomId:str,card:teams.AdaptiveCard)->teams.MessageAdaptiveCard Componentsmention(person:teams.Person|teams.Membership)->strmention(personId:str,displayName:str)->str(BROKEN) returns a formatted string for mentioning a user in a messagebot.api.message.create(text = f"hello {bot.mention(person)}")send_help(source:teams.Message)->teams.Messagereply to a message with help text which includescommands the bot recognizescommand descriptionshears(regex:str|list[str]|Pattern,name:str=None,description:str=None)@decorator, listen for user giving the bot with a commandon(resource:str,event:str=None)@decorator, listen for other resource eventswebexbotsdk.util#API| Framework helper methods^APImethodsis_bot(person:teams.Person|teams.Membership)->booldetermine whether a person is a human or botwebexbotsdk.tinydb^TOC|@DOCS| TinyDB libraryContributingCreate anIssueto:Ask a questionRequest a featureReport a bugFile a complaintPull requests from branches/forks are also welcome! I will try to respond to them ASAP.