I have recently been developing a Teams app that is supposed to have multiple uses to help the classroom. I have created a simple bot using the Teams Python SDK that quotes whatever the user says, and I have tested it using a localhost and Microsoft devtools.

import asyncio
import re
from microsoft_teams.api import MessageActivity, TypingActivityInput
from microsoft_teams.apps import ActivityContext, App
from microsoft_teams.devtools import DevToolsPlugin
app = App(plugins=[DevToolsPlugin()])
@app.on_message_pattern(re.compile(r"hello|hi|greetings"))
async def handle_greeting(ctx: ActivityContext[MessageActivity]) -> None:
"""Handle greeting messages."""
await ctx.send("Hello! How can I assist you today?")
@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
"""Handle message activities using the new generated handler system."""
await ctx.reply(TypingActivityInput())
if "reply" in ctx.activity.text.lower():
await ctx.reply("Hello! How can I assist you today?")
else:
await ctx.reply(f"You said '{ctx.activity.text}'")
def main():
asyncio.run(app.start())
if __name__ == "__main__":
main()
The problem I am now facing is that I am having trouble sideloading it into teams using said SDK. It keeps telling me I have a or that there’s a different error. I don’t get an error code, so I have to go through multiple different solutions. Eventually I will find the error, but it will take time so until I can successfully add the bot to a Teams channel, I will not make any more development to its logic.
Leave a Reply