Webhooks são retornos de chamada HTTP configurados para cada conta. Eles são acionados quando ações como a criação de uma mensagem ocorrem no Trino AI. Vários webhooks podem ser criados para uma única conta.
Como adicionar um webhook?
Passo 1. Acesse Configurações → Integrações → Webhooks . Clique no botão "Configurar".

Passo 2. Clique no botão "Adicionar novo webhook". Um modal será aberto. Insira a URL para a qual a solicitação POST deve ser enviada. Em seguida, você precisa selecionar os eventos que deseja assinar. Esta opção permitirá que você ouça apenas os eventos relevantes no Trino AI.

O Trino AI enviará uma solicitação POST com o seguinte payload para os URLs configurados para várias atualizações em sua conta.
Um exemplo de carga útil do webhook
{
"event": "message_created", // The name of the event
"id": "1", // Message ID
"content": "Hi", // Content of the message
"created_at": "2020-03-03 13:05:57 UTC", // Time at which the message was sent
"message_type": "incoming", // This will have a type incoming, outgoing or template. The user from the widget sends incoming messages, and the agent sends outgoing messages to the user.
"content_type": "enum", // This is an enum, it can be input_select, cards, form or text. The message_type will be template if content_type is one og these. Default value is text
"content_attributes": {} // This will an object, different values are defined below
"source_id": "", // This would the external id if the inbox is a Twitter or Facebook integration.
"sender": { // This would provide the details of the agent who sent this message
"id": "1",
"name": "Agent",
"email": "agent@example.com"
},
"contact": { // This would provide the details of the user who sent this message
"id": "1",
"name": "contact-name"
},
"conversation": { // This would provide the details of the conversation
"display_id": "1", // This is the ID of the conversation which you can see in the dashboard.
"additional_attributes": {
"browser": {
"device_name": "Macbook",
"browser_name": "Chrome",
"platform_name": "Macintosh",
"browser_version": "80.0.3987.122",
"platform_version": "10.15.2"
},
"referer": "<http://www.Trinoai.com>",
"initiated_at": "Tue Mar 03 2020 18:37:38 GMT-0700 (Mountain Standard Time)"
}
},
"account": { // This would provide the details of the account
"id": "1",
"name": "TrinoAI",
}
}
Eventos de webhook suportados no Trino AI
O Trino AI publica vários eventos nos endpoints de webhook configurados.
Cada evento tem sua estrutura de carga útil baseada no tipo de modelo em que atua. A seção a seguir descreve os principais objetos que usamos no Trino AI e seus atributos.
Objetos
Uma carga útil de evento pode incluir qualquer um dos seguintes objetos. Os vários tipos de objetos suportados pelo Trino AI estão listados abaixo.
Conta
{
"id": "integer",
"name": "string"
}
Caixa de entrada
{
"id": "integer",
"name": "string"
}
Contato
{
"id": "integer",
"name": "string",
"avatar": "string",
"type": "contact",
"account": {
// <...Account Object>
}
}
Usuário
{
"id": "integer",
"name": "string",
"email": "string",
"type": "user"
}
Conversa
{
"additional_attributes": {
"browser": {
"device_name": "string",
"browser_name": "string",
"platform_name": "string",
"browser_version": "string",
"platform_version": "string"
},
"referer": "string",
"initiated_at": {
"timestamp": "iso-datetime"
}
},
"can_reply": "boolean",
"channel": "string",
"id": "integer",
"inbox_id": "integer",
"contact_inbox": {
"id": "integer",
"contact_id": "integer",
"inbox_id": "integer",
"source_id": "string",
"created_at": "datetime",
"updated_at": "datetime",
"hmac_verified": "boolean"
},
"messages": ["Array of message objects"],
"meta": {
"sender": {
// Contact Object
},
"assignee": {
// User Object
}
},
"status": "string",
"unread_count": "integer",
"agent_last_seen_at": "unix-timestamp",
"contact_last_seen_at": "unix-timestamp",
"timestamp": "unix-timestamp",
"account_id": "integer"
}
Mensagem
{
"id": "integer",
"content": "string",
"message_type": "integer",
"created_at": "unix-timestamp",
"private": "boolean",
"source_id": "string / null",
"content_type": "string",
"content_attributes": "object",
"sender": {
"type": "string - contact/user"
// User or Contact Object
},
"account": {
// Account Object
},
"conversation": {
// Conversation Object
},
"inbox": {
// Inbox Object
}
}
Um exemplo de carga útil do webhook
{
"event": "event_name"
// Attributes related to the event
}
Eventos de Webhook
O Trino AI suporta os seguintes eventos de webhook. Você pode se inscrever neles ao configurar um webhook no painel ou usando a API.
conversa_criada
Este evento será acionado quando uma nova conversa for criada na conta. O payload do evento é o seguinte.
{
"event": "conversation_created"
// <...Conversation Attributes>
}
conversa_atualizada
Este evento será acionado quando houver uma alteração em qualquer um dos atributos na conversa.
{
"event": "conversation_updated",
"changed_attributes": [
{
"<attribute_name>": {
"current_value": "",
"previous_value": ""
}
}
]
// <...Conversation Attributes>
}
status_da_conversação_alterado
Este evento será acionado quando o status da conversa for alterado.
Observação: se você estiver usando APIs de bot de agente em vez de webhooks, esse evento ainda não é compatível.
{
"event": "conversation_status_changed"
// <...Conversation Attributes>
}
mensagem_criada
Este evento será acionado quando uma mensagem for criada em uma conversa. O payload do evento é o seguinte.
{
"event": "message_created"
// <...Message Attributes>
}
mensagem_atualizada
Este evento será acionado quando uma mensagem for atualizada em uma conversa. O payload do evento é o seguinte.
{
"event": "message_updated"
// <...Message Attributes>
}
webwidget_acionado
Este evento será acionado quando o usuário final abrir o widget de chat ao vivo.
{
"event": "webwidget_triggered",
"id": "",
"contact": {
// <...Contact Object>
},
"inbox": {
// <...Inbox Object>
},
"account": {
// <...Account Object>
},
"current_conversation": {
// <...Conversation Object>
},
"source_id": "string",
"event_info": {
"initiated_at": {
"timestamp": "date-string"
},
"referer": "string",
"widget_language": "string",
"browser_language": "string",
"browser": {
"browser_name": "string",
"browser_version": "string",
"device_name": "string",
"platform_name": "string",
"platform_version": "string"
}
}
}
digitação_de_conversação_ativada
Este evento é acionado quando um agente começa a digitar em uma conversa. Pode ser uma nota privada ou uma mensagem para o cliente. Você pode usar o **is_private**sinalizador para distinguir entre os dois.
{
"event": "conversation_typing_on",
"conversation": { ...<Conversation Object> },
"user": { ... <User / AgentBot / Captain Object> },
"is_private": true
}
digitação_de_conversação_desligada
Este evento é acionado quando um agente para de digitar ou quando sai da janela de conversa.
{
"event": "conversation_typing_off",
"conversation": { ...<Conversation Object> },
"user": { ... <User / AgentBot / Captain Object> },
"is_private": true
}