Teams bot send direct message to user without user adding the bot

stav pistiner 0 Reputation points
2024-07-10T20:31:13.84+00:00

Hey,

I created a teams bot app using the developer portal. I added the following permissions which as to my understanding will let me send messages to users who haven't install my bot but are a part of a team that installed the bot for.

I understood that I should firstly create a conversation for the bot and the user so I tried using the following API

POST /teams/v3/conversations

{

"bot": {

"id": "ASDAD"

},

"members": [

{

"id": "sdas"

}

],

"channelData": {

"tenant": {

"id": "asdasd"

}

}

}

The response was

Bot not installed in user's personal space. How can I achieve sending messages to users when there isn't an active conversation?

Microsoft Teams | Development
Microsoft Teams | Development
Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad-MSFT 10,186 Reputation points Microsoft External Staff Moderator
    2024-07-11T06:00:47.93+00:00

    The bot firstly needs to be installed by user. Then you can create the conversation if it doesn't exist, or you don't know the conversationId. Create the conversation only once and store the conversationId value or conversationReference object.

    To create the conversation, you need a aadObjectId or userId, tenantId, and serviceUrl.

    Ref: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet#create-the-conversation

    https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conv-proactive?tabs=csharp#examples

    0 comments No comments

Your answer

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