Este documento descreve a API de disparo de mensagens, suas propriedades, tipos suportados e exemplos de uso.
Nome | Tipo | Obrigatório | Padrão |
---|---|---|---|
accountId | number | Sim | - |
contact | Contact | Sim | - |
message | Message | Sim | - |
channelId | number | Sim | - |
messageTimeout | number | Não | - |
isPrivate | boolean | Não | false |
tagId | number | Não | - |
queueId | number | Não | - |
session | Session | Não | - |
status | string (automatic|pending|solved) | Não | automatic |
ticketId | number | Não | - |
userId | number | Não | - |
summary | string | Não | - |
from | string | Não | - |
queued | boolean | Não | true |
messageTimeoutBehavior | string (solve|flow) | Não | solve |
messageTimeoutFlowId | number | Não | - |
responseFlowId | number | Não | - |
context | Context | Não |
type Contact = {
name: string;
phone: string;
};
Representa o contato que receberá a mensagem.
type Message =
| {
type: "text";
body: string;
}
| {
type: "contact";
name: string;
phone: string;
businessDescription: string;
}
| {
type: "template";
variables?: string[];
headerVariables?: string[];
buttonVariables?: string[];
name: string;
}
| {
type: "image";
url: string;
caption?: string;
}
| {
type: "pdf";
url: string;
fileName: string;
caption?: string;
}
| {
type: "document";
url: string;
filename: string;
caption: string;
};
Define o tipo de mensagem enviado e suas propriedades específicas.
type SendMessageFromApiSession = {
context: Record<string, string>;
};
Permite passar variáveis de contexto que serão armazenadas na sessão do chatbot e acessíveis no fluxo a partir do objeto session. Exemplo: Na API envie session.context.nota_fiscal = 10020. No chatbot poderá acessar essa variável utilizando {{session.nota_fiscal}} que retornará o valor "10020".
type Context = {
header: string;
body: string;
buttons?: ButtonContext[];
};
type ButtonContext = {
type: 'link' | 'telephone' | 'copy';
title: string;
content: string;
};
Permite adicionar contexto no envio da mensagem
curl --request POST \
--url https://api.sacflow.io/api/send-message \
--header 'Authorization: Bearer API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"accountId": ACCOUNT_ID,
"channelId": CHANNEL_ID,
"contact": {
"name": "CONTACT_NAME",
"phone": "CONTACT_PHONE"
},
"message": {
"type": "template",
"name": "TEMPLATE_NAME"
},
"queued": false
}'
curl --request POST \
--url https://api.sacflow.io/api/send-message \
--header 'Authorization: Bearer API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"accountId": ACCOUNT_ID,
"channelId": CHANNEL_ID,
"contact": {
"name": "CONTACT_NAME",
"phone": "CONTACT_PHONE"
},
"message": {
"type": "template",
"name": "TEMPLATE_NAME",
"variables": ["VAR1", "VAR2"]
}
}'
Para mais informações, entre em contato com o suporte da API.