# API interactiva de WhatsApp

### Mensajes interactivos&#x20;

Para el envío de mensajes Interactivos seguiremos el patrón del resto de tipos de mensajes que se pueden ver.

## Message

<table><thead><tr><th width="152">Campo</th><th width="138">Obligatorio</th><th width="198">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>interactive</strong></td><td>Sí</td><td>Campo utilizado para enviar mensajes de tipo interactivo</td><td>Interactive Message</td></tr></tbody></table>

## Interactive Message

<table><thead><tr><th width="172">Campo</th><th>Obligatorio</th><th>Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>messageInteractiveType</strong></td><td>Si</td><td>Tipo de mensaje interactivo. Opciones disponibles: LIST y REPLY_BUTTON</td><td>String</td></tr><tr><td><strong>header</strong></td><td>No</td><td>Contenido del encabezado</td><td>Header</td></tr><tr><td><strong>body</strong></td><td>Si</td><td>Texto principal</td><td>Body</td></tr><tr><td><strong>footer</strong></td><td>No</td><td>contenido del pie de página</td><td>Footer</td></tr><tr><td><strong>listAction</strong></td><td>Cuando el tipo de mensaje interactivo es LISTA</td><td>Contiene los parámetros de un mensaje de lista.</td><td>ListAction</td></tr><tr><td><strong>replyButtonAction</strong></td><td>Cuando el tipo de mensaje interactivo es REPLY_BUTTON</td><td>Contiene los parámetros de un mensaje de botones de respuesta.</td><td>ReplyButtonAction</td></tr><tr><td><strong>alternativeText</strong></td><td>No</td><td>El texto que se enviará si el celular del usuario no soporta mensajes de tipo interactivo</td><td>String</td></tr></tbody></table>

### Encabezamiento&#x20;

Si el mensaje contiene un encabezado, **se debe completar exactamente uno de los campos a continuación.**&#x20;

Si el mensaje es del tipo LISTA, solo se acepta el campo de texto.

<table><thead><tr><th width="182.00000000000003">Campo</th><th width="307">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>text</strong></td><td>Texto de cabecera. Máximo 60 caracteres. Permite el uso de emojis y rebajas.</td><td>String</td></tr><tr><td><strong>document</strong></td><td>Objeto complejo de tipo Documento.</td><td>Document</td></tr><tr><td><strong>video</strong></td><td>Objeto complejo de tipo Video.</td><td>Video</td></tr><tr><td><strong>image</strong></td><td>Objeto complejo de tipo Image.</td><td>Image</td></tr><tr><td><strong>location</strong></td><td>Objeto complejo de tipo Video.Location.</td><td>Location</td></tr></tbody></table>

## **Image**

<table><thead><tr><th width="136">Campo</th><th width="153">Obligatorio</th><th width="235">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>type</strong></td><td>Si</td><td>Tipo/extensión de la imagen que se enviará en el mensaje. Opciones disponibles: JPG, JPEG, PNG.</td><td>String</td></tr><tr><td><strong>url</strong></td><td>Si</td><td>URL del contenido (imagen) que se enviará.</td><td>String</td></tr></tbody></table>

## **Video**

<table><thead><tr><th width="142">Campo</th><th width="133">Obligatorio</th><th width="252">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>type</strong></td><td>Sim</td><td>Tipo/extensión del vídeo que se enviará en el mensaje. Opciones disponibles: MP4.</td><td>String</td></tr><tr><td><strong>url</strong></td><td>Sim</td><td>URL del contenido (video) que se enviará.</td><td>String</td></tr></tbody></table>

## **Document**

<table><thead><tr><th width="166">Campo</th><th width="148">Obligatorio</th><th width="260">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>type</strong></td><td>Si</td><td>Tipo/extensión del documento que se enviará en el mensaje. Opciones disponibles: PDF.</td><td>String</td></tr><tr><td><strong>url</strong></td><td>Si</td><td>URL del contenido (documento) que se enviará.</td><td>String</td></tr></tbody></table>

## **Location**

<table><thead><tr><th width="155">Campo</th><th width="147">Obligatorio</th><th width="217">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>name</strong></td><td>No</td><td>Nombre del lugar.</td><td>String</td></tr><tr><td><strong>address</strong></td><td>No</td><td>Dirección del sitio.</td><td>String</td></tr><tr><td><strong>geoPoint</strong></td><td>Sm</td><td>Coordenadas de formato: latitud, longitud</td><td>String</td></tr></tbody></table>

## Body/Footer

<table><thead><tr><th width="133">Campo</th><th width="131">Obligatorio</th><th width="231">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>text</strong></td><td>Si</td><td><p>No puede ser una cadena vacía. Se permiten emojis y rebajas.</p><p></p><p><strong>Cuerpo:</strong> máximo 1024 caracteres. </p><p><strong>Pie de página:</strong> Máximo 60 caracteres.</p></td><td>String</td></tr></tbody></table>

## ListAction

<table><thead><tr><th width="146">Campo</th><th width="134">Obligatorio</th><th width="244">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>button</strong></td><td>Si</td><td>Contenido que se escribirá en el botón.</td><td>String</td></tr><tr><td><strong>sections</strong></td><td>Si</td><td>Lista de secciones. Debe haber al menos una sección.</td><td>Section[]</td></tr></tbody></table>

## **Section**

<table><thead><tr><th width="136">Campo</th><th width="143">Obligatorio</th><th width="265">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>rows</strong></td><td>Si</td><td>Lista de filas. Debe haber al menos una fila y un máximo de 10 sumando todas las secciones.</td><td>Row[]</td></tr></tbody></table>

## **Row**

<table><thead><tr><th width="169">Campo</th><th width="135">Obligatorio</th><th width="224">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>identifier</strong></td><td>Si</td><td>identificador de fila</td><td>String</td></tr><tr><td><strong>title</strong></td><td>Si</td><td>título de la fila</td><td>String</td></tr><tr><td><strong>description</strong></td><td>No</td><td>descripción de la fila</td><td>String</td></tr></tbody></table>

## ReplyButtonAction

<table><thead><tr><th width="151">Campo</th><th width="138">Obligatorio</th><th width="221">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>buttons</strong></td><td>Si</td><td>Lista con 1, 2 o 3 Botones</td><td>Button[]</td></tr></tbody></table>

## **Button**

<table><thead><tr><th width="124">Campo</th><th width="159">Obligatorio</th><th>Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>reply</strong></td><td>Si</td><td>estructura de botones</td><td>Reply</td></tr></tbody></table>

**Reply**

<table><thead><tr><th width="112">Campo</th><th width="152">Obligatorio</th><th width="237">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>title</strong></td><td>Si</td><td>Texto que se escribirá en el botón. Máximo 20 caracteres.</td><td>String</td></tr><tr><td><strong>payload</strong></td><td>Si</td><td>Información que se devolverá en la devolución de llamada. Máximo 256 caracteres.</td><td>String</td></tr></tbody></table>

## Exemplos de requests

**`LIST`**

```javascript
{
  "destinations": [
    {
      "correlationId": "MyCorrelationId",
      "destination": "5519900001111"
    }
  ],
  "message": {
    "interactive": {
      "messageInteractiveType": "LIST",
      "header": {
        "text": "Sample text"
      },
      "body": {
        "text": "Main message text"
      },
      "footer": {
        "text": "Footer text"
      },
      "listAction": {
        "button": "button text",
        "sections": [
        {
          "rows": [
            {
              "identifier": "9ab8d65e-d389-4123-b97b-702e658cc9e4",
              "title": "August 7, 11:00",
              "description": "Saturday, August 7, 2021. 11:00AM"
            },
            {
              "identifier": "2051afef-e000-47d0-99a5-7d96c17968b2",
              "title": "August 7, 15:00",
              "description": "Saturday, August 7, 2021. 3:00PM"
            },
            {
              "identifier": "55baac93-a513-45d0-ad9e-2e2271861fc8",
              "title": "August 9, 11:00",
              "description": "Monday, August 9, 2021. 11:00AM"
            },
            {
              "identifier": "e2703f03-689c-4d1e-b0e9-4045d6687605",
              "title": "August 9, 15:00",
              "description": "Monday, August 9, 2021. 4:00PM"
            }
          ]
        }
      ]
      },
      "alternativeText": "Simple message text"
    }
  }
}
```

## **`REPLY_BUTTON`**

```javascript
{
  "destinations": [
    {
      "correlationId": "MyCorrelationId",
      "destination": "5519900001111"
    }
  ],
  "message": {
    "interactive": {
      "messageInteractiveType": "REPLY_BUTTON",
      "header": {
        "text": "Sample text",
        "image": {
          "type": "JPG",
          "url": "http://...jpg"
        },
        "video": {
          "type": "MP4",
          "url": "http://...mp4"
        },
        "document": {
          "type": "PDF",
          "url": "http://...pdf"
        },
        "location": {
          "geoPoint": "-22.894180,-47.047960",
          "name": "Sinch",
          "address": "Av. Cel. Silva Telles"
        }
      },
      "body": {
        "text": "Main message text"
      },
      "footer": {
        "text": "Footer text"
      },
      "replyButtonAction": {
        "buttons": [
        {
          "reply": {
            "title": "Display Text 1",
            "payload": "callback_payload_1"
          }
        },
        {
          "reply": {
            "title": "Display Text 2",
            "payload": "callback_payload_2"
          }
        }
       ],
      },
      "alternativeText": "Simple message text"
    }
  }
}
```

## Callback de mensagem interactive

#### Callback

<table><thead><tr><th width="177.00000000000003">Campos</th><th width="279">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>total</strong></td><td>Número de devoluciones de llamada en esta solicitud</td><td>Long</td></tr><tr><td><strong>data</strong></td><td>Lista de mensajes enviados por el usuario</td><td>Data[]</td></tr><tr><td><strong>clientInfo</strong></td><td>Información sobre el cliente que recibe los mensajes.</td><td>ClientInfo</td></tr></tbody></table>

## Data

<table><thead><tr><th width="143.00000000000003">Campos</th><th width="306">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>id</strong></td><td>identificador de mensaje</td><td>String</td></tr><tr><td><strong>source</strong></td><td>Número de teléfono de la persona que envió el mensaje</td><td>String</td></tr><tr><td><strong>origin</strong></td><td>Número de teléfono de la cuenta de WhatsApp que recibió el mensaje</td><td>String</td></tr><tr><td><strong>userProfile</strong></td><td>Perfil del usuario que envió el mensaje</td><td>UserProfile</td></tr><tr><td><strong>correlationId</strong></td><td>ID único enviado por el cliente al enviar el mensaje que se devolverá en la devolución de llamada. Opcional.</td><td>String</td></tr><tr><td><strong>campaignId</strong></td><td>Campaña relacionada con el envío</td><td>String</td></tr><tr><td><strong>campaignAlias</strong></td><td>Alias ​​de campaña relacionados con el envío</td><td>String</td></tr><tr><td><strong>message</strong></td><td>Mensaje recibido</td><td>Message</td></tr><tr><td><strong>receivedDate</strong></td><td>Fecha en que se recibió el mensaje Formato: aaaa-MM-dd'T'HH:mm:ssZ</td><td>String</td></tr><tr><td><strong>receivedAt</strong></td><td>Fecha en que se recibió el mensaje, utilizando el formato Unix_time</td><td>Long</td></tr><tr><td><strong>extraInfo</strong></td><td>Información adicional relacionada con el mensaje. Formato: JSON</td><td>String</td></tr><tr><td><strong>session</strong></td><td>información de la sesión</td><td>Session</td></tr></tbody></table>

## UserProfile

<table><thead><tr><th width="159.00000000000003">Campo</th><th width="223">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td>name</td><td>Nombre de usuario de WhatsApp</td><td>String</td></tr><tr><td>whatsAppId</td><td>telefono de usuario</td><td>String</td></tr></tbody></table>

## Session

<table><thead><tr><th width="174.00000000000003">Campo</th><th>Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td>sessionId</td><td>ID de sesión de este usuario</td><td>String</td></tr><tr><td>createdAt</td><td>Marca de tiempo de la creación de esta sesión</td><td>Long</td></tr></tbody></table>

## Message

<table><thead><tr><th width="171.00000000000003">Campo</th><th width="295">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>type</strong></td><td>Tipo de mensaje enviado por el usuario: TEXT - IMAGE - AUDIO - DOCUMENT - STICKER - BUTTON - ORDER</td><td>String</td></tr><tr><td><strong>messageText</strong></td><td>Texto del mensaje enviado por el usuario. Para las respuestas de lista, es igual al título de fila en el que el usuario hizo clic</td><td>String</td></tr><tr><td><strong>mediaUrl</strong></td><td>Url para descargar medios subidos por el usuario</td><td>String</td></tr><tr><td><strong>mimeType</strong></td><td>Mime type de archivo subido por el usuario</td><td>String</td></tr><tr><td><strong>caption</strong></td><td>Etiqueta de medios enviada por el usuario</td><td>String</td></tr><tr><td><strong>location</strong></td><td>Ubicación enviada por el usuario</td><td>Location</td></tr><tr><td><strong>contacts</strong></td><td>Lista de contactos enviada por el usuario</td><td>Contact[]</td></tr><tr><td><strong>interactive</strong></td><td>Campos relacionados con los mensajes interactivos</td><td>ReceivedInteractive</td></tr></tbody></table>

## ReceivedInteractive

<table><thead><tr><th width="162.00000000000003">Campo</th><th width="330">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>type</strong></td><td>Tipo de mensaje interactivo. Puede ser: LIST_REPLY o BUTTON_REPLY</td><td>String</td></tr><tr><td><strong>listReply</strong></td><td>Respuesta de lista (LIST)</td><td>ListReply</td></tr><tr><td><strong>buttonReply</strong></td><td>Respuesta del botón (REPLY_BUTTON)</td><td>ButtonReply</td></tr></tbody></table>

## **ListReply**

<table><thead><tr><th width="171.00000000000003">Campo</th><th width="303">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>rowIdentifier</strong></td><td>Identificador de la fila que el usuario seleccionó</td><td>String</td></tr><tr><td><strong>rowTitle</strong></td><td>Título de la fila que el usuario seleccionó</td><td>String</td></tr></tbody></table>

## **ButtonReply**

| Campo       | Detalles                                        | Tipo   |
| ----------- | ----------------------------------------------- | ------ |
| **payload** | Texto establecido en el momento del envío       | String |
| **title**   | Título del botón en el que el usuario hizo clic | String |

## ClientInfo

<table><thead><tr><th width="186.00000000000003">Campo</th><th width="325">Detalles</th><th>Tipo</th></tr></thead><tbody><tr><td><strong>customerId</strong></td><td>customerId del cliente que recibe el mensaje</td><td>Long</td></tr><tr><td><strong>subAccountId</strong></td><td>subAccountId del cliente que recibe el mensaje</td><td>Long</td></tr><tr><td><strong>userId</strong></td><td>ID de usuario del cliente que recibe el mensaje.</td><td>Long</td></tr></tbody></table>
