Send direct message to a user via MS Teams programmatically

nettech 146 Reputation points


We are currently using teams web hooks extensively to send notifications to teams channels.

Sometimes we have situations where we need to send a teams message to a user directly, but have not found a way to accomplish this task using powershell.

Is it possible to make an Invoke-RestMethod PowerShell call to send a message to a user directly?

Thank you

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,824 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.
2,916 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prasad-MSFT 5,706 Reputation points Microsoft Vendor

    It is not possible to send a direct message to a user using Teams Incoming Webhook. The Incoming Webhook is designed to post messages to a specific channel, not to individual users. However, you can achieve this by creating a Teams bot application. Teams bot applications can send messages to individual users, group chats, and public channels.

    To send a message to a user directly, you would need to use the Microsoft Bot Framework and the Teams SDK. You would need to capture the user's Teams-specific identifiers, which you can do by fetching the roster or user profile data, subscribing to conversation events, or using Microsoft Graph.

    var turnContext = new TurnContext(new AdapterWithErrorHandler(new ConfigurationCredentialProvider(Configuration)), activity);
    var conversationParameters = new ConversationParameters
        IsGroup = false,
        Bot = turnContext.Activity.Recipient,
        Members = new ChannelAccount[] { new ChannelAccount(userId) },
        TenantId = tenantId
    await ((BotFrameworkAdapter)turnContext.Adapter).CreateConversationAsync(
        async (t1, c1) =>
            var reply = MessageFactory.Text("Hello, user!");
            await t1.SendActivityAsync(reply, c1);

    Please refer to the Microsoft Bot Framework documentation and Teams SDK documentation for more detailed information on how to create a bot and send messages to users.


    Prasad Das


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Prashant Bali (Upwork Global Inc) 75 Reputation points Microsoft Vendor

    It is now possible to send messages to personal chat(1:1) or to group chat in Microsoft Teams using Microsoft Graph API. And yes, the messages will be displayed in the Teams application using Microsoft Graph API.

    Please refer the "1:1 and group chat messages" section from the below microsoft documentation link:

    chatMessage resource type

    Also, below is the graph API to send a message to any conversation you want using Post HTTP method :{user-id}/chats/{chat-id}/messages

    To fetch {user-id} and {chat-id}, please follow the below steps using Get HTTP method:

    Fetch the user id of a logged-in user or user id of other user using below graph API's:

    Fetch the conversation/chat id of a user:{id}/chats

    As of now, there is no graph API to reply to a personal chat but we can reply to any team's channel message using Microsoft Graph API.

    If the response is helpful, please click "Accept Answer" and upvote it.