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

# Button Messages

> Send interactive buttons via WhatsApp

Button messages let users respond with a single tap, perfect for quick actions and surveys.

## Send Button Message

<CodeGroup>
  ```typescript TypeScript theme={null}
  const message = await client.messages.send({
    to: "+14155551234",
    text: "How would you rate our service?",
    channel: "whatsapp",
    messageType: "buttons",
    content: {
      buttons: [
        { id: "good", title: "Good" },
        { id: "average", title: "Average" },
        { id: "poor", title: "Poor" }
      ]
    }
  });
  ```

  ```python Python theme={null}
  message = client.messages.send(
      to="+14155551234",
      text="How would you rate our service?",
      channel="whatsapp",
      message_type="buttons",
      content={
          "buttons": [
              {"id": "good", "title": "Good"},
              {"id": "average", "title": "Average"},
              {"id": "poor", "title": "Poor"}
          ]
      }
  )
  ```

  ```ruby Ruby theme={null}
  message = client.messages.send(
    to: "+14155551234",
    text: "How would you rate our service?",
    channel: "whatsapp",
    message_type: "buttons",
    content: {
      buttons: [
        { id: "good", title: "Good" },
        { id: "average", title: "Average" },
        { id: "poor", title: "Poor" }
      ]
    }
  )
  ```

  ```go Go theme={null}
  message, err := client.Messages.Send(context.TODO(), zavudev.MessageSendParams{
      To:          zavudev.String("+14155551234"),
      Text:        zavudev.String("How would you rate our service?"),
      Channel:     zavudev.String("whatsapp"),
      MessageType: zavudev.String("buttons"),
      Content: &zavudev.MessageContentParams{
          Buttons: []zavudev.ButtonParams{
              {ID: zavudev.String("good"), Title: zavudev.String("Good")},
              {ID: zavudev.String("average"), Title: zavudev.String("Average")},
              {ID: zavudev.String("poor"), Title: zavudev.String("Poor")},
          },
      },
  })
  ```

  ```php PHP theme={null}
  $message = $client->messages->send([
      'to' => '+14155551234',
      'text' => 'How would you rate our service?',
      'channel' => 'whatsapp',
      'messageType' => 'buttons',
      'content' => [
          'buttons' => [
              ['id' => 'good', 'title' => 'Good'],
              ['id' => 'average', 'title' => 'Average'],
              ['id' => 'poor', 'title' => 'Poor'],
          ],
      ],
  ]);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.zavu.dev/v1/messages \
    -H "Authorization: Bearer zv_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "to": "+14155551234",
      "text": "How would you rate our service?",
      "channel": "whatsapp",
      "messageType": "buttons",
      "content": {
        "buttons": [
          { "id": "good", "title": "Good" },
          { "id": "average", "title": "Average" },
          { "id": "poor", "title": "Poor" }
        ]
      }
    }'
  ```
</CodeGroup>

## Specifications

| Property           | Requirement                       |
| ------------------ | --------------------------------- |
| Max buttons        | 3                                 |
| Button ID          | Max 256 chars, unique per message |
| Button title       | Max 20 chars                      |
| Body text (`text`) | Required, max 1024 chars          |

## Handling Button Responses

When a user taps a button, you receive a webhook:

```json theme={null}
{
  "event": "message.received",
  "data": {
    "from": "+14155551234",
    "type": "button_reply",
    "button": {
      "id": "good",
      "title": "Good"
    }
  }
}
```

<Tip>
  Use meaningful IDs like `confirm_order` or `cancel_order` to make webhook handling easier.
</Tip>

## Use Cases

* Customer satisfaction surveys
* Order confirmations (Yes/No)
* Appointment scheduling options
* Quick response options
* A/B testing user preferences
