Search code examples
javabotframeworkmicrosoft-teams

Send proactive message without prior interaction


I use this sample: 16.proactive-messages - as the base for my bot and it works fine, but I'd like to extend it, so that it can send messages in a group chat without anyone interacting with it first (like sending a "Hello I'm up!" message at startup), because currently it can only respond if someone has mentioned the bot after it has initialized.

Perhaps there is a proper way to get the group chat(s) where the bot resides at the bot initialization?


Solution

  • I've answered before some tips on Proactive messaging, please see here for that.

    To answer your question though, the bot can definitely start the engagement, either by replying to an existing message in a group chat or starting a completely new thread in the chat. However, it does require to have been installed initially, either by a user or programmatically (e.g. Graph API). That part only needs to be done once, then you can capture the conversation reference and use it again anytime thereafter. That is shown in the sample I link to in my other answer I referenced above.