> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kapso.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Send template

> Send WhatsApp template messages

Sends WhatsApp template messages. Templates must be pre-approved by Meta.

## Configuration

* `whatsapp_config_id`: WhatsApp connection to use (optional; falls back to the conversation)
* `phone_number_id`: WhatsApp Business phone number ID to use (preferred for local/API source)
* `template_id`: WhatsApp template identifier
* `parameters`: Template parameter values (see formats below)
* `provider_model_name`: Required when using AIField in parameters
* `to_phone_number`: Override destination phone number (optional; required for observer mode flows)

## Workflow library example

```javascript theme={null}
workflow.addNode("send_order_template", {
  type: "send_template",
  templateId: "<template-id>",
  phoneNumberId: "<phone-number-id>",
  parameters: [
    {
      type: "BODY",
      parameters: [
        { type: "text", text: "{{vars.customer_name}}" },
        { type: "text", text: "{{vars.order_id}}" }
      ]
    }
  ]
});
```

## Parameter formats

The `parameters` field supports two formats:

### Meta components format (recommended)

Use Meta's native components structure for full control over template parameters:

```json theme={null}
[
  {
    "type": "BODY",
    "parameters": [
      { "type": "text", "text": "{{user_name}}" },
      { "type": "text", "text": "{{order_id}}" }
    ]
  }
]
```

**Multi-component example** (header + body + buttons):

```json theme={null}
[
  {
    "type": "HEADER",
    "parameters": [
      { "type": "text", "text": "{{customer_name}}" }
    ]
  },
  {
    "type": "BODY",
    "parameters": [
      { "type": "text", "text": "{{order_number}}" },
      { "type": "text", "text": "{{order_total}}" }
    ]
  },
  {
    "type": "BUTTON",
    "sub_type": "URL",
    "index": "0",
    "parameters": [
      { "type": "text", "text": "{{tracking_id}}" }
    ]
  }
]
```

**Named parameters**:

```json theme={null}
[
  {
    "type": "BODY",
    "parameters": [
      { "type": "text", "parameter_name": "customer_name", "text": "{{user_name}}" },
      { "type": "text", "parameter_name": "order_id", "text": "{{order_number}}" }
    ]
  }
]
```

Alternative hash format using `components` key:

```json theme={null}
{
  "components": [...]
}
```

### Legacy format

Simple array or hash format (still supported):

```json theme={null}
["{{user_name}}", "{{order_id}}"]
```

Or with explicit template\_params key:

```json theme={null}
{
  "template_params": ["{{user_name}}", "{{order_id}}"]
}
```

## Template setup

Templates must be created and approved in Meta Business Manager first. Common templates:

* Welcome messages
* Order confirmations
* Appointment reminders
* Support ticket updates

## Usage patterns

**Order workflow**

```mermaid theme={null}
graph LR
    A[Function<br/>Get order] --> B[Send template<br/>Order confirmation]
    B --> C[Wait for Response]
```

**Notification workflow**

```mermaid theme={null}
graph LR
    A[API Trigger] --> B[Send template<br/>Alert message]
```
