# Send Direct Message — Microsoft Teams

> Send a one-on-one message to a user, even if you have never chatted with them before. Reuses the existing one-on-one chat when there is one, otherwise creates it. To post to an existing group chat, use Send Chat Message instead. See the…

- Key: `microsoft_teams-send-direct-message`
- Type: Action (Write)
- Version: 0.0.1
- App: Microsoft Teams (`microsoft_teams`) — https://pipedream.com/apps/microsoft-teams.md
- This page (HTML): https://pipedream.com/apps/microsoft-teams/actions/send-direct-message
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/microsoft_teams/actions/send-direct-message/send-direct-message.mjs

## Description

Send a one-on-one message to a user, even if you have never chatted with them before. Reuses the existing one-on-one chat when there is one, otherwise creates it. To post to an existing group chat, use **Send Chat Message** instead. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-post?view=graph-rest-1.0&tabs=http#example-5-create-a-one-on-one-chat-using-user-principal-name)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `user` | `string` | Yes | The recipient's user principal name (usually their work email, e.g. alex@contoso.com) or Microsoft Entra user ID (e.g. 82af01c5-f7cc-4a2e-a728-3a5df21afd9d, the Object ID under Users in the Microsoft Entra admin center) |
| `message` | `string` | Yes | Message to be sent |
| `contentType` | `string` | No | Text message or HTML message |
| `isGuest` | `boolean` | No | Set to true when the recipient is a guest user in your organization, which Microsoft Graph requires to join with the guest role. Leave false for members of your organization. Identify guests by user ID or their #EXT# user principal name, not their email address. Users in other organizations are not supported. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "microsoft_teams",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "microsoft_teams-send-direct-message",
  arguments: {
    user: "User",
    message: "Message",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "microsoft_teams-send-direct-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    microsoft_teams: { authProvisionId: "apn_xxxxxxx" },
    user: "User",
    message: "Message",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "microsoft_teams-send-direct-message",
    "configured_props": {
      "microsoft_teams": { "authProvisionId": "apn_xxxxxxx" },
      "user": "User",
      "message": "Message"
    }
  }'
```

---

- App: https://pipedream.com/apps/microsoft-teams.md · All apps: https://pipedream.com/apps
