# Send Message — HubSpot

> Sends a message to a thread. See the documentation

- Key: `hubspot-send-message`
- Type: Action (Write)
- Version: 0.0.8
- App: HubSpot (`hubspot`) — https://pipedream.com/apps/hubspot.md
- This page (HTML): https://pipedream.com/apps/hubspot/actions/send-message
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/hubspot/actions/send-message/send-message.mjs

## Description

Sends a message to a thread. [See the documentation](https://developers.hubspot.com/docs/api-reference/conversations-conversations-inbox-&-messages-v3/public-message/post-conversations-v3-conversations-threads-threadId-messages)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `inboxId` | `string` | Yes | The ID of an inbox Options are loaded from the connected account. |
| `senderActorId` | `string` | Yes | The ID of the sender actor Options are loaded from the connected account. |
| `channelId` | `string` | Yes | The ID of a channel Options are loaded from the connected account. |
| `threadId` | `string` | Yes | The ID of a thread Options are loaded from the connected account. |
| `channelAccountId` | `string` | Yes | The ID of a channel account Options are loaded from the connected account. |
| `recipientType` | `string` | Yes | The type of identifier. HS_EMAIL_ADDRESS for email addresses; HS_PHONE_NUMBER for a phone number; CHANNEL_SPECIFIC_OPAQUE_ID for channels that use their own proprietary identifiers, like Facebook Messenger or LiveChat. Use the "List Messages" action to locate a CHANNEL_SPECIFIC_OPAQUE_ID. |
| `recipientValue` | `string` | Yes | The value of the recipient identifier. For HS_EMAIL_ADDRESS, this is the email address. For HS_PHONE_NUMBER, this is the phone number. For CHANNEL_SPECIFIC_OPAQUE_ID, this is the proprietary identifier. |
| `text` | `string` | Yes | The text content of the message |
| `fileId` | `string` | No | The ID of a file uploaded to HubSpot Options are loaded from the connected account. |
| `subject` | `string` | No | The subject of the message |

## 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": "hubspot",
      },
    },
  },
)

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: "hubspot-send-message",
  arguments: {
    inboxId: "Inbox ID",
    senderActorId: "Sender Actor ID",
  },
})
```

**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: "hubspot-send-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    hubspot: { authProvisionId: "apn_xxxxxxx" },
    inboxId: "Inbox ID",
    senderActorId: "Sender Actor ID",
  },
})

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": "hubspot-send-message",
    "configured_props": {
      "hubspot": { "authProvisionId": "apn_xxxxxxx" },
      "inboxId": "Inbox ID",
      "senderActorId": "Sender Actor ID"
    }
  }'
```

---

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