Bot Framework v4 - Bot Initiate Conversation
Bot Framework v4 - Bot Initiate Conversation
Bot Framework v4 - Bot Initiate Conversation
Re: Bot Framework v4 - Bot Initiate Conversation
MS Teams calls that a "Proactive Message" (note: Bot Framework generally defines a "proactive message" as sending a user a message not related to current conversation, that you have a reference for. Teams lumps a few things into this category). You can read more about [how to use proactive messaging](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bot-conversations/bots-conv-proactive) from the official Teams docs. Or, more specifically, [creating a channel conversation](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#team-member-or-bot-addition).
The gist of it is that you need to [capture a `conversationUpdate` and check for a new member added to the conversation](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#team-member-or-bot-addition) or [fetch the team roster](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-context#fetching-the-team-roster), then you [send the proactive message](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#team-member-or-bot-addition).
Note: For MS Teams, the user or team will have to add the bot first:
Bots can create new conversations with an individual Microsoft Teams user as long as your bot has user information obtained through previous addition in a personal or team scope. This information enables your bot to proactively notify them. For instance, if your bot was added to a team, it could query the team roster and send users individual messages in personal chats, or a user could @mention another user to trigger the bot to send that user a direct message.
Some developers come across `401: Unauthorized` errors when using proactive messaging, especially if the bot was restarted for some reason and the bot is attempting to re-initiate a proactive message. You can read more about preventing that [by using `trustServiceUrl` from this Sample](https://git
*(Réponse tronquée)*
The gist of it is that you need to [capture a `conversationUpdate` and check for a new member added to the conversation](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#team-member-or-bot-addition) or [fetch the team roster](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-context#fetching-the-team-roster), then you [send the proactive message](https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-notifications#team-member-or-bot-addition).
Note: For MS Teams, the user or team will have to add the bot first:
Bots can create new conversations with an individual Microsoft Teams user as long as your bot has user information obtained through previous addition in a personal or team scope. This information enables your bot to proactively notify them. For instance, if your bot was added to a team, it could query the team roster and send users individual messages in personal chats, or a user could @mention another user to trigger the bot to send that user a direct message.
Some developers come across `401: Unauthorized` errors when using proactive messaging, especially if the bot was restarted for some reason and the bot is attempting to re-initiate a proactive message. You can read more about preventing that [by using `trustServiceUrl` from this Sample](https://git
*(Réponse tronquée)*