How to send proactive message to users if conversation id not have

manav 5 Reputation points
2025-01-23T11:18:50.6266667+00:00

I’m currently building a Teams application that includes both a bot and a tab. I want the bot to proactively send messages to users. While I know that adapter.sendActivity can be used to send messages, it only works for users within the current context. However, in my application, I need to send messages to users selected from the organization (within the Teams app) — even if they have never interacted with the bot before.

Since I can’t save the conversation ID for users who haven’t interacted with the bot, I need to create a new conversation for them. While exploring the documentation, I found the adapter.createConversationAsync method, which seems like a potential solution. While I understand the required parameters, constructing the Activity object seems challenging. If I need to use the adapter.createConversationAsync method, could you please provide a detailed example of how to implement it? It seems to require a lot of information, and I want to ensure I do it correctly.

Could you guide me on the best way to proactively send messages to selected users through the bot, especially when creating a new conversation? Any tips, examples, or best practices would be greatly appreciated! I am using the latest version of the botbuilder npm package.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
882 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,738 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,882 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,512 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,213 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sayali-MSFT 3,351 Reputation points Microsoft Vendor
    2025-01-23T13:05:57.2666667+00:00

    Hello manav, To proactively send messages to users in Microsoft Teams using a bot, even if they have never interacted with the bot before, you can use the adapter.createConversationAsync method. This method allows you to create a new conversation with a user and send a message to them.

    To send a proactive message to a user, a group chat, or a team, your bot must have the requisite access to send the message. For a group chat or team, the app that contains your bot must be first installed in that location.
    You can refer the below document and code sample-
    1.https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet
    2.https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/5f341fdd6d57f68654218007047f1c9ccfcf8aaa/samples/bot-conversation/nodejs/bots/teamsConversationBot.js#L511


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.