Ir para o conteúdo

Objeto do WhatsApp

O objeto whats_app permite que você modifique ou crie mensagens do WhatsApp por meio dos nossos endpoints de envio de mensagens.

Objeto WhatsApp

{
  "app_id": (required, string) see App Identifier,
  "subscription_group_id": (required, string) the ID of your subscription group,
  "message_variation_id": (optional, string) used when providing a campaign_id to specify which message variation this message should be tracked under,
  "message_type": (required, string) the type of WhatsApp message being sent under the `message` key (template_message | text_response_message | text_image_response_message | quick_reply_response_message | list_response_message | flow_response_message | carousel_response_message),
  "message": (required, object) The message object that must include the required fields based on the selected `message_type`. Below are the specific message structures for each type. Refer to the relevant message type for the required fields and their format.
}

Tipos de mensagem

template_message

{
  "template_name": (required, string) the WhatsApp template name for the message,
  "template_language_code": (required, string) the language code of the WhatsApp template for the message,
  "header_variables": (optional, header variables object) an object to specify header variable values for specified template_name, required if the header has variables; see object specification below,
  "body_variables": (optional, body variable object) an object to specify body variable values for specified template_name, required if the body has variables; see object specification below,
  "button_variables": (optional, button variables object) an object to specify button variable values for specified template_name, required if buttons have variables; see object specification below,
  "header_media_uri": (optional, string) URI to the header media, if the header is of type IMAGE in specified template_name. Only IMAGE and TEXT header types are supported by the messages/send API,
  "carousel_cards": (optional, array) an array of carousel card objects, required if the specified template_name is a carousel template; see object specification below
}

Cada cartão de carrossel preenche um cartão de um modelo de carrossel aprovado, em ordem. O cartão no índice 0 preenche o primeiro cartão do modelo.

{
  "header_media_uri": (required, string) URI to the card's header media; must be Braze-hosted media,
  "header_media_type": (required, string) The type of the card's header media (image | video),
  "body_variables": (optional, body variables object) Values for the card's body variables, in the same format as the template-level body_variables,
  "button_variables": (optional, button variables object) Values for the card's button variables, in the same format as the template-level button_variables
}
Restrições
  • carousel_cards: deve conter entre 2 e 10 cartões, correspondendo ao número de cartões do modelo aprovado.
  • header_media_uri: deve se referir a uma mídia hospedada na biblioteca de mídia da Braze.
  • header_media_type: todos os cartões devem usar o mesmo tipo de mídia, correspondendo ao modelo aprovado.
Exemplo
{
  "template_name": "weekly_picks",
  "template_language_code": "en",
  "body_variables": {
    "0": "Jane"
  },
  "carousel_cards": [
    {
      "header_media_uri": "https://braze-images.com/card1.png",
      "header_media_type": "image",
      "body_variables": {
        "0": "Runner X"
      }
    },
    {
      "header_media_uri": "https://braze-images.com/card2.png",
      "header_media_type": "image",
      "body_variables": {
        "0": "Trail Pro"
      },
      "button_variables": {
        "0": "/promo/123"
      }
    }
  ]
}
Objeto de variáveis de cabeçalho

O objeto header_variables permite que você especifique valores para variáveis de cabeçalho no modelo de WhatsApp. Cada chave é o índice da variável do modelo de WhatsApp (indexado a partir de zero) a ser substituído pelo valor especificado.

{
  "$TEMPLATE_VARIABLE_INDEX_0": "$TEMPLATE_VARIABLE_VALUE_0"
}

Atualmente, apenas zero ou uma variável de cabeçalho pode ser especificada.

Exemplo
{
  "0": "Check it out!"
}
Objeto de variáveis do corpo

O objeto body_variables permite que você especifique valores para variáveis do corpo no modelo de WhatsApp. Cada chave é o índice da variável do modelo de WhatsApp (indexado a partir de zero) a ser substituído pelo valor especificado.

{
  "$TEMPLATE_VARIABLE_INDEX_0": "$TEMPLATE_VARIABLE_VALUE_0",
  "$TEMPLATE_VARIABLE_INDEX_1": "$TEMPLATE_VARIABLE_VALUE_1"
}
Exemplo
{
  "0": "Check it out!",
  "1": "It's pretty neat."
}
Objeto de variáveis de botão

O objeto button_variables permite que você especifique valores para variáveis de botão no modelo de WhatsApp. Cada chave é o índice da variável do modelo de WhatsApp (indexado a partir de zero) a ser substituído pelo valor especificado.

{
  "$TEMPLATE_VARIABLE_INDEX_1": "$TEMPLATE_VARIABLE_VALUE_1"
}

Atualmente, apenas uma variável de botão pode ser especificada, que é o componente de caminho de uma URL de call-to-action. O índice da variável deve corresponder ao índice do botão de URL CTA no modelo. Por exemplo, se o botão CTA é o segundo botão no seu modelo, use o índice de variável “1”.

Exemplo
{
  "1": "/marketing/promotion123"
}

Mensagens de resposta

text_response_message

{
  "body": (required, string) the body of the message to send,
  "preview_url": (optional, boolean) whether WhatsApp should render a preview of links included in body
}
Exemplo
{
  "body": "Check out our new deals at https://braze.com",
  "preview_url": true
}

text_image_response_message

{
  "image_uri": (required, string) the uri of the image to send,
  "caption": (optional, string) the caption for the image being sent
}
Exemplo
{
  "image_uri": "https://braze.com/promotion.jpg",
  "caption": "This won't last for long, check it out!"
}

quick_reply_response_message

{
  "body": (required, string) the body of the message to send,
  "header_image_uri": (optional, string) the URI of the image to send as the message header (only valid if header_text not present),
  "header_text": (optional, string) the text to send as the message header (only valid if header_image_uri not present),
  "footer": (optional, string) the footer of the message to send,
  "buttons": (required, array) array of Button objects. Will render in message based on order in array.
}
Objeto de botão
{
  "text": (required, string) the text of the button
}
Exemplo
{
  "body": "Want to keep hearing from us?",
  "buttons": [
    {
      "text": "Yes!"
    },
    {
      "text": "No thanks"
    }
  ]
}

list_response_message

O tipo list_response_message permite enviar uma mensagem baseada em lista no WhatsApp. Esse tipo de mensagem inclui uma lista de itens com os quais o destinatário pode interagir.

{
  "header": (optional, string) the header of the message to send,
  "body": (required, string) the body of the message to send,
  "footer": (optional, string) the footer of the message to send,
  "list": (required, object) the list object that contains:
    "list_button_text": (required, string) the text that will appear on the list button,
    "list_sections": (required, array) an array of List Section Objects
}

Objeto de seção de lista

{
  "section_title": (required, string) The title of the section,
  "list_rows": (required, array) An array of List Row Objects
}

Objeto de linha de lista

{
  "row_title": (required, string) The title of the row,
  "row_description": (optional, string) The description for the row
}
Restrições
  • list_sections: deve ter pelo menos uma seção.
  • list_rows: um máximo de 10 linhas pode ser incluído em todas as seções.
  • row_description: opcional para cada linha.
Exemplo
{
  "body": "Here is a list of options to choose from:",
  "list": {
    "list_button_text": "Choose an option",
    "list_sections": [
      {
        "section_title": "Section 1",
        "list_rows": [
          {
            "row_title": "Option 1"
          },
          {
            "row_title": "Option 2",
            "row_description": "Description for Option 2"
          }
        ]
      },
      {
        "section_title": "Section 2",
        "list_rows": [
          {
            "row_title": "Option 3"
          },
          {
            "row_title": "Option 4"
          },
          {
            "row_title": "Option 5"
          }
        ]
      }
    ]
  }
}

flow_response_message

O tipo flow_response_message permite enviar uma mensagem baseada em fluxo no WhatsApp. Esse tipo de mensagem inclui um fluxo interativo que o destinatário pode completar.

{
  "header_text": (optional, string) the header text of the message to send,
  "body": (required, string) the body of the message to send,
  "footer": (optional, string) the footer of the message to send,
  "flow_button": (required, object) the flow button object that contains:
    "caption": (required, string) the text that will appear on the flow button,
    "flow_id": (required, string) the unique identifier of the WhatsApp Flow,
  "generate_custom_attribute": (optional, boolean) whether to save flow response on the user profile and generate a custom attribute upon responding to this flow message
}
Objeto de botão de fluxo
{
  "caption": (required, string) The text displayed on the button,
  "flow_id": (required, string) The ID of the flow
}
Restrições
  • flow_button: deve incluir tanto caption quanto flow_id.
  • caption: máximo de 20 caracteres.
  • flow_id: deve ser um ID de fluxo publicado válido.
Exemplo
{
  "body": "Please complete your order details",
  "flow_button": {
    "caption": "Start Order",
    "flow_id": "594425479261596"
  },
  "generate_custom_attribute": true
}

O tipo carousel_response_message permite enviar um carrossel interativo de cartões de mídia pelos quais os usuários podem deslizar como mensagem de resposta. Cada cartão possui mídia, texto de corpo opcional e botões de resposta rápida ou um botão de website.

{
  "body": (required, string) the body of the message to send,
  "carousel_button_type": (required, string) the button type used by every card (quick_reply | url),
  "cards": (required, array) an array of Card objects. Cards render in the carousel in array order.
}
Objeto de cartão
{
  "media_uri": (required, string) the URI of the card's media,
  "media_type": (required, string) the type of the card's media (image | video),
  "body_text": (optional, string) the body text of the card,
  "buttons": (required for quick_reply, array) an array of button label strings,
  "cta_url_button": (required for url, object) the website button object that contains:
    "display_text": (required, string) the text displayed on the button,
    "url": (required, string) the URL the button opens
}
Restrições
  • cards: deve conter entre 2 e 10 cartões.
  • media_type: todos os cartões devem usar o mesmo tipo de mídia.
  • body_text: máximo de 160 caracteres por cartão.
  • buttons: para quick_reply, todos os cartões devem ter o mesmo número de botões, com no máximo dois por cartão.
  • cta_url_button: para url, todos os cartões devem incluir um cta_url_button.
Exemplo com botões de resposta rápida
{
  "body": "Check out this week's picks!",
  "carousel_button_type": "quick_reply",
  "cards": [
    {
      "media_uri": "https://example.com/card1.png",
      "media_type": "image",
      "body_text": "Runner X - now 20% off",
      "buttons": ["Shop now", "Not for me"]
    },
    {
      "media_uri": "https://example.com/card2.png",
      "media_type": "image",
      "body_text": "Trail Pro - back in stock",
      "buttons": ["Shop now", "Not for me"]
    }
  ]
}
Exemplo com botões de website
{
  "body": "Check out this week's picks!",
  "carousel_button_type": "url",
  "cards": [
    {
      "media_uri": "https://example.com/card1.png",
      "media_type": "image",
      "body_text": "Runner X - now 20% off",
      "cta_url_button": {
        "display_text": "Visit",
        "url": "https://example.com/runner-x"
      }
    },
    {
      "media_uri": "https://example.com/card2.png",
      "media_type": "image",
      "body_text": "Trail Pro - back in stock",
      "cta_url_button": {
        "display_text": "Visit",
        "url": "https://example.com/trail-pro"
      }
    }
  ]
}
New Stuff!