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

# Mensagem Interativa

> Envie mensagens interativas com botões e listas de opções via WhatsApp

# Mensagem Interativa

O tipo `INTERACTIVE` permite enviar mensagens com elementos interativos, como botões de resposta rápida e listas de opções selecionáveis. O corpo interativo é definido pelo campo `payload`, um objeto livre repassado ao provedor de destino.

## Payload

```json theme={null}
{
  "channelId": "uuid-do-canal",
  "content": {
    "type": "INTERACTIVE",
    "to": {
      "type": "WHATSAPP",
      "number": "5511999999999"
    },
    "interactiveType": "button",
    "payload": {
      "body": {
        "text": "Deseja confirmar seu agendamento para amanha as 14h?"
      },
      "action": {
        "buttons": [
          { "type": "reply", "reply": { "id": "confirm", "title": "Confirmar" } },
          { "type": "reply", "reply": { "id": "reschedule", "title": "Remarcar" } }
        ]
      }
    }
  }
}
```

## Campos

<ParamField body="content.type" type="string" required>
  Deve ser `"INTERACTIVE"`.
</ParamField>

<ParamField body="content.to" type="Address" required>
  Endereço do destinatário. Veja [formatos de endereço](/mensagens/visao-geral#enderecamento-address).
</ParamField>

<ParamField body="content.interactiveType" type="string" required>
  Subtipo da mensagem interativa. Define como o `payload` é interpretado pelo provedor. Valores comuns: `button` (botões de resposta rápida) e `list` (lista de opções).
</ParamField>

<ParamField body="content.payload" type="object" required>
  Objeto livre com o conteúdo interativo. A plataforma **não valida** nem interpreta essa estrutura -- ela é repassada verbatim ao provedor de destino. O formato depende do `interactiveType` e das capacidades do provedor.
</ParamField>

<Note>
  O `payload` é um objeto opaco. Sua estrutura é definida pelo provedor de destino (por exemplo, o formato de mensagens interativas do WhatsApp), e não pela MessageFy. Consulte a documentação do provedor para montar o `payload` correto para cada `interactiveType`.
</Note>

## Exemplos

### Botões de resposta rápida

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-dev.messagefy.io/api/v1/message/SendMessage \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: sua-api-key-aqui" \
    -d '{
      "channelId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "content": {
        "type": "INTERACTIVE",
        "to": {
          "type": "WHATSAPP",
          "number": "5511999999999"
        },
        "interactiveType": "button",
        "payload": {
          "body": {
            "text": "Deseja confirmar seu agendamento para amanha as 14h?"
          },
          "action": {
            "buttons": [
              { "type": "reply", "reply": { "id": "confirm", "title": "Confirmar" } },
              { "type": "reply", "reply": { "id": "reschedule", "title": "Remarcar" } }
            ]
          }
        }
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api-dev.messagefy.io/api/v1/message/SendMessage",
      headers={
          "Content-Type": "application/json",
          "X-API-KEY": "sua-api-key-aqui"
      },
      json={
          "channelId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "content": {
              "type": "INTERACTIVE",
              "to": {
                  "type": "WHATSAPP",
                  "number": "5511999999999"
              },
              "interactiveType": "button",
              "payload": {
                  "body": {
                      "text": "Deseja confirmar seu agendamento para amanha as 14h?"
                  },
                  "action": {
                      "buttons": [
                          {"type": "reply", "reply": {"id": "confirm", "title": "Confirmar"}},
                          {"type": "reply", "reply": {"id": "reschedule", "title": "Remarcar"}}
                      ]
                  }
              }
          }
      }
  )
  print(response.json())
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api-dev.messagefy.io/api/v1/message/SendMessage",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "sua-api-key-aqui",
      },
      body: JSON.stringify({
        channelId: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        content: {
          type: "INTERACTIVE",
          to: {
            type: "WHATSAPP",
            number: "5511999999999",
          },
          interactiveType: "button",
          payload: {
            body: {
              text: "Deseja confirmar seu agendamento para amanha as 14h?",
            },
            action: {
              buttons: [
                { type: "reply", reply: { id: "confirm", title: "Confirmar" } },
                { type: "reply", reply: { id: "reschedule", title: "Remarcar" } },
              ],
            },
          },
        },
      }),
    }
  );
  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

### Lista de opções

```json theme={null}
{
  "channelId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "content": {
    "type": "INTERACTIVE",
    "to": {
      "type": "WHATSAPP",
      "number": "5511999999999"
    },
    "interactiveType": "list",
    "payload": {
      "body": {
        "text": "Selecione o assunto do seu atendimento:"
      },
      "action": {
        "button": "Ver opcoes",
        "sections": [
          {
            "title": "Atendimento",
            "rows": [
              { "id": "support", "title": "Suporte tecnico", "description": "Problemas com o produto" },
              { "id": "sales", "title": "Vendas", "description": "Falar com um consultor" },
              { "id": "billing", "title": "Financeiro", "description": "Boletos e pagamentos" }
            ]
          }
        ]
      }
    }
  }
}
```

<Tip>
  A resposta do destinatário a uma mensagem interativa (botão clicado ou item de lista selecionado) chega pelo seu canal de webhook. Use os `id` definidos no `payload` para identificar a opção escolhida.
</Tip>

### Enviando como resposta a outra mensagem

Para vincular a mensagem interativa a uma mensagem anterior, inclua o campo `quotedMessage`:

```json theme={null}
{
  "channelId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "content": {
    "type": "INTERACTIVE",
    "to": {
      "type": "WHATSAPP",
      "number": "5511999999999"
    },
    "interactiveType": "button",
    "payload": {
      "body": { "text": "Podemos ajudar com mais alguma coisa?" },
      "action": {
        "buttons": [
          { "type": "reply", "reply": { "id": "yes", "title": "Sim" } },
          { "type": "reply", "reply": { "id": "no", "title": "Nao, obrigado" } }
        ]
      }
    },
    "quotedMessage": {
      "messageId": "20CFBA298FAB68AA75D3B369EDB5C805",
      "participant": "5511999999999@s.whatsapp.net",
      "body": "Meu problema foi resolvido, valeu!",
      "type": "TEXT"
    }
  }
}
```

## Resposta

```json theme={null}
{
  "packageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

<Warning>
  Mensagens interativas dependem do suporte do provedor de destino. Botões e listas funcionam no WhatsApp, mas há limites do próprio provedor (por exemplo, quantidade máxima de botões e de itens por lista). Consulte a documentação do provedor antes de montar o `payload`.
</Warning>
