I can't seem to figure out how to proactively message a MS teams channel using a Python Bot (botframework).
- An user installs my third-party MS teams bot, adding it to one of their Teams channels.
- My Bot needs to send ad-hoc messages as part of an event from an unrelated back-end system.
The botframework does not let you message channels at will, it needs a conversation reference. You can get a conversation reference in various ways, such as someone messaging the bot, or fetching the list of channels and constructing a conversationId
from that.
Reading the documentation
The documentation will have you believe that it is in fact possible to send message at will, using the following steps:
- Get the user ID or team/channel ID (if needed).
- Create the conversation or conversation thread (if needed).
- Get the conversation ID.
- Send the message.
For step 1, how/when do I get the channel ID if there are no events that my Bot has been added to a channel?
For step 2, how do I create a conversation if I don't know what team channels there are?
Conclusion
Does someone know how to send a message to a MS Teams channel using a Python app/bot? It should not require user interaction. The app/bot gets added to a Teams channel, and it should immediately post a message inside this channel.