# Send WhatsApp Template Message — Whautomate

> Send a pre-defined WhatsApp message template to a contact. See the documentation

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

## Description

Send a pre-defined WhatsApp message template to a contact. [See the documentation](https://help.whautomate.com/product-guides/whautomate-rest-api/messages)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `contactId` | `string` | Yes | The unique identifier of the contact Options are loaded from the connected account. |
| `templateName` | `string` | Yes | The WhatsApp Template from your Whautomate Account. |
| `templateLanguage` | `string` | Yes | The language of the WhatsApp Template. |
| `locationId` | `string` | Yes | The location id of the contact Options are loaded from the connected account. |
| `headerMediaUrl` | `string` | No | The URL of the header media. |
| `headerTextParameters` | `string[]` | No | The variables used in the header of your WhatsApp Template. |
| `bodyTextParameters` | `string[]` | No | The variables used in the body of your WhatsApp Template. |
| `buttonUrlParameters` | `string[]` | No | The placeholders used in the buttons of your WhatsApp Template. |

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

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: "whautomate-send-whatsapp-template-message",
  arguments: {
    contactId: "Contact ID",
    templateName: "Template Name",
  },
})
```

**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: "whautomate-send-whatsapp-template-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    whautomate: { authProvisionId: "apn_xxxxxxx" },
    contactId: "Contact ID",
    templateName: "Template Name",
  },
})

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": "whautomate-send-whatsapp-template-message",
    "configured_props": {
      "whautomate": { "authProvisionId": "apn_xxxxxxx" },
      "contactId": "Contact ID",
      "templateName": "Template Name"
    }
  }'
```

---

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