Help Center
SuporteLanguage
  • Help Center 🚀
  • Introdução
  • Cadastro
  • Definições
  • BOT BUILDER
    • Criar o Bot
      • Importar bot
      • Criando meu primeiro BOT
      • Configurações do Bot
        • Geral
        • Controle de Versão
        • Compartilhamento
        • Comportamento
    • Fluxo da Conversa
      • Importador de Q&A
      • Mensagem
        • Encerrar Atendimento
        • Tipos de formatação de Texto
        • O que é uma mensagem template ?
      • Filtro
      • Etapa Existente
      • Rest API
        • Exemplo de utilização da etapa Rest API
      • Javascript
        • Manipulação de Objetos
      • E-mail
      • Controle Humano
      • Webview
      • Encaminha a outro bot
      • Testar Bot
      • Ação de Tempo
    • NLP
      • Intenção
      • Entidade
      • Treinamento
      • Como utilizar o DialogFlow?
    • Canais
      • Microsoft Teams
      • Whatsapp
        • Como utilizar um Número de teste da Cosmobots
        • Como posso adquirir o selo de verificação para o meu WhatsApp?
        • Cadastrar templates na plataforma
        • Adicionando botões ao canal whatsapp
        • Provedores
          • Twilio
            • Como comprar e configurar um número na Twilio?
            • Inserir webhook em número Twilio
          • Dialog 360
            • Aprovar templates
      • Instagram
        • Como filtrar menções do Instagram
      • Google Assistant
      • Facebook
        • Como verificar minha empresa no Facebook Business?
        • Não consigo clicar no botão de verificar conta. O que fazer?
      • Workplace
      • Chat Widget
        • Landing
        • Publicando Widget
        • Webhook
    • Broadcast
    • Dados
      • Conversas
      • Campos
      • Objetos
      • Como acessar e exportar os Dados coletados pelo Bot?
      • Layouts
        • Cosmo Desk
        • Pesquisa
    • Dashboard
      • Performance dos Atendentes
      • Indicadores
    • Explorer
      • Códigos
      • Alterações
    • Integrações
      • Pipefy
        • Acessando campos retornados em webhook
      • RD Station
      • Analíticos
  • COSMO DESK
    • Live Chat
      • Download Livechat
      • 🔔Receber notificações em Live Chat
    • Configurações
      • 🔄Filas de Atendimento
      • 🤖Regras de atendimento
      • 🕐SLA
      • 💬Mensagem Rápidas
      • 📑Tags
      • 💨Status de Ausente
  • CONFIGURAÇÕES
    • Perfil
    • Cadastrar Usuários
    • Consumo
    • Feriados
  • API
    • V1 - Records
    • V1 - Index
    • V1 - Send Message
    • V1 - Broadcast Messages
  • Available Languages
  • Outros
    • Saber Mais
      • Utilizando Hyperlink no canal Widget
      • Formatação em negrito e itálico para canais Widget e Whatsapp
      • Erro 403
      • Pesquisa NPS
      • Gerar URL de arquivos
      • Enviar o usuário para um fluxo específico caso ele responda 2 ou mais vezes errado.
      • 🍪Ativar ou Desativar Cookies
      • 🧹Limpeza de Cache
      • 🆗Validar idade
      • 🆗Validar e-mail
      • 🆗Validar CPF
      • 🆗Dialog - Validar mensagens do tipo imagem em Filtro.
      • 🆗Validar CNPJ
      • 🆗Validar arquivos
      • Como visualizar Logs de Atendimento
      • Pular Etapa de Cadastro
    • Exemplos de Códigos JavaScript
      • Envio de Imagens/Anexos/Vídeos/Áudios
      • Adicionar TAGS pelo fluxo
      • Limpar TAGS pelo fluxo
      • Parar o bot por x tempo
      • Validar data digitada pelo usuário
      • Converter arquivos em B64
      • Validador de resposta a templates
      • Validar menção no Instagram
  • FAQ
    • Criar modelos de mensagem para sua conta do WhatsApp Business
    • Como excluir uma mensagem do WhatsApp enviada usando a API?
    • Regra 24 horas do WhatsApp
Powered by GitBook
On this page
  • Endpoint
  • Authentication
  • Sending Message
  • Contact Object
  • Session Object
  • Desk Object
  • Message Array [Object ]
  • Message > Data (if type is Text)
  • Message > Data (if type is Buttons)
  • Message > Data (if type is Cards)
  • Message > Data (if type is Media)
  • Response Sync
  • Response Async
  • Examples of Request
  • Sending Text Destination: Bot
  • Sending Text with Buttons Destination: Contact
  • Sending Audio Destination: Bot
  • Sending Image Destination: Contact
  • Receiving Message

Was this helpful?

  1. API

V1 - Send Message

Send and receive messages, to single contacts per request, on channels connected to CosmoBots

This document is intended to be used for developers using CosmoBots API to send and receive messages, to single contacts per request, on channels connected to CosmoBots.

To send messages to registered channels we are considering you already have connected the channel to your Bot on CosmoBots.

Endpoint

POST https://api.cosmobots.io/messages/v1/send

Authentication

Every request needs to have these two parameters on the header. You may retrieve both on the Integration section of the platform. Follow these steps:

  • Login into the platform

  • Choose the Bot

  • On the left sidebar menu, choose Integrations, then API

  • Choose the Send Message API

  • Click on Enable API

  • Now you can copy both token and channelId to use on the requests

Header

Type

Description

token

String

Required. Token exclusive to the Bot, to be used on this API.

channel_id

String

Required. ID of the Channel that will receive the messages

Sending Message

Here are the body fields used during this request. The format is JSON.

Field

Type

Description

destination

String

Required.

Destination that the message will go.

  • bot

  • contact

  • desk

If bot: it will send to the bot and reply through the webhook if sync or on the same request through a response if async).

If contact: it will send to the contact. And any reply back from the contact will be handled through the webhook.

Contact Object

Field

Type

Description

id

String

Required. ID of the Contact on CosmoBots. If it is a new contact then just inform "new_contact"

external_id

String

ID of the Contact on any external Database

first_name

String

First Name of the Contact

last_name

String

Last Name of the Contact

mobile_phone

String

Mobile Phone of the Contact. It is required when using these channels: whatsapp, rcs, apple. It needs to provide the number with complete format, including country code. Ex.: 5511999999999

custom

Object (Key/Value)

Custom fields about the contact profile

Session Object

Field

Type

Description

id

String

Required. ID of the Session

control

String

It shows who controls the conversation. The options are:

  • bot

  • human

desk

Object

Provide the desk platform that is being used by the human agent

context

Object

Information about the context of the conversation

Desk Object

Field

Type

Description

provider

String

Required. Provider of the Desk platform

agent

Object < String >

Information about the person handling the conversation

  • id

  • name

  • email

  • group

Message Array [Object ]

Field

Type

Description

data

Object

Required. Data related to the message

type

String

Types of Message. Options are:

  • text

  • buttons

  • cards

  • media

  • payload

template_id

String

ID (or Name) of Template approved by Facebook to be sent.

Message > Data (if type is Text)

Field

Type

Description

text

String

Text of the message

Message > Data (if type is Buttons)

Field

Type

Description

title

String

Required. Text of the Button (Caption)

type

String

Required. Type of Button, having the value related to the field payload. Options are:

  • text

  • url

  • payload

value

String

Required. Data related to the payload when the button is clicked

Message > Data (if type is Cards)

Field

Type

Description

title

String

Required. Title of the Card

subtitle

String

Subtitle of the Card

image_url

String

Image Url of the Card

buttons

Array [ Object ]

List of Buttons

Message > Data (if type is Media)

Field

Type

Description

type

String

Required. Type of media. Options are:

  • image

  • audio

  • video

  • document

url

String

Required. Url of the Media

name

String

Name of the Media (Caption)

mime_type

String

The media type standard

Response Sync

Field

Type

Description

status

String

Status of the Message

  • sent

  • error

contact_id

String

ID of the Contact

session_id

String

ID of the Session of the ongoing conversation

message_ids

Array [String]

Array with the ID's of the messages sent

Response Async

Field

Type

Description

id

String

ID confirmation of message queued

Examples of Request

Sending Text Destination: Bot

POST https://api.cosmobots.io/messages/v1/send

{
   "destination":"bot",
   "contact": {
       "id": "new_contact",
       "external_id": "123456",
       "firstName": "John",
       "phone": "5511999999999",
       "custom": {
          "email":"test@test.com"
       }
   },
   "message":[{
      "type":"text",
      "data":{
         "text":"How was my service?"
      }
   }]
}

Sending Text with Buttons Destination: Contact

POST https://api.cosmobots.io/messages/v1/send

{
   "destination":"contact",
   "contact": {
       "id": "XXXXXXXXX",
       "external_id": "123456",
       "phone": "5511999999999"
   },
   "message":[{
      "type":"buttons",
      "data":{
         "text":"How was my service?",
         "buttons":[
            {
               "title":"Good",
               "type":"text",
               "value":"good"
            },
            {
               "title":"Great",
               "type":"text",
               "value":"great"
            }
         ]
      }
   }]
}

Sending Audio Destination: Bot

POST https://api.cosmobots.io/messages/v1/send

{
   "destination":"bot",
   "channel":"whatsapp",
   "contact": {
       "id": "new_contact",
       "external_id": "123456",
       "firstName": "John",
       "phone": "5511999999999",
       "custom": {
          "email":"test@test.com"
       }
   },
   "message":[{
      "type":"media",
      "data":{
         "type":"audio",
         "name":"sample_audio",
         "url":"https://xy.com/x.wav",
         "mime_type":"audio/wav"
      }
   }]
}

Sending Image Destination: Contact

POST https://api.cosmobots.io/messages/v1/send

{
   "destination":"contact",
   "channel":"whatsapp",
   "contact": {
       "id": "XXXXXXXXX",
       "external_id": "123456",
       "phone": "5511999999999"
   },
   "message":[{
      "type":"media",
      "data":{
         "type":"image",
         "name":"sample_image",
         "url":"https://xy.com/x.jpg",
         "mime_type":"image/jpg"
      }
   }]
}

Receiving Message

To receive messages coming from CosmoBots, you have to register your endpoint on our webhook. You may find the webhook setup on the Channels section of the platform. Follow these steps:

  • Login into the CosmoBots platform

  • Choose the Bot

  • On the left sidebar menu, choose Channel, then the specific channel you are using

  • On the Webhook Url field, include the endpoint that will receive the requests

The Body fields are the same as the fields from the Body of the Sending Message request above.

PreviousV1 - IndexNextV1 - Broadcast Messages

Last updated 2 years ago

Was this helpful?