API Mensagem de Lista
🧩 Envia uma mensagem com uma Lista de opções, para o usuário escolher uma resposta.
- o Título será a resposta devolvida quando o lead escolher
API: Básica
Verifique aqui os Pré-Requisitos para utilizar APIs
Endpoint
https://{BACKEND_URL}/api/messages/sendList
Método
POST
Autenticação
Bearer {seutokenaqui}
Payload
{
"number": "554498108792",
"body": "Selecione a melhor opção:",
"optionList": {
"buttonLabel": "Abrir lista de opções",
"options": [
{
"id": "1",
"title": "Título A",
"description": "Descrição A"
},
{
"id": "2",
"title": "Título B",
"description": "Descrição B"
}
]
}
}
➡️ “number”: telefone do destinatário no formato ddi ddd numero (somente números). ➡️ “body”: texto logo acima do botão. ➡️ “buttonLabel”: texto do botão que ao clicar exibe as opções da lista. ➡️ “options”: cada opção da lista, sendo que:– id: define o id da opção– title: título da opção– description: descrição da opção Adicione mais opções se desejar! ###### Modelos
API Utilize o código em requisições HTTPS com ferramentas como cURL ou bibliotecas de integração.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{BACKEND_URL}/api/messages/sendList',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"number": "554498108792",
"body": "Selecione a melhor opção:",
"optionList": {
"buttonLabel": "Abrir lista de opções",
"options": [
{
"id": "1",
"title": "Título A",
"description": "Descrição A"
},
{
"id": "2",
"title": "Título B",
"description": "Descrição B"
}
]
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer {seutokenaqui}' //Token cadastrado na conexão
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
FLOWBUILDER Insira o código em um bloco de “Http Request / Code” do tipo REQUISIÇÃO.
Os trechos delimitados por {{...}} são placeholders no formato Mustaches e não precisam ser alterados. Eles serão automaticamente substituídos pelos valores correspondentes no momento da execução.
// definir
let endpoint = "https://{{backendURL}}/api/messages/sendList";
let method = "POST";
let payload = {
"number": "{{number}}",
"openTicket": "1",
"queueId": "16",
"body": "Selecione a melhor opção:",
"optionList": {
"buttonLabel": "Abrir lista de opções",
"options": [
{
"id": "1",
"title": "Título A",
"description": "Descrição A"
},
{
"id": "2",
"title": "Título B",
"description": "Descrição B"
},
{
"id": "3",
"title": "Título C",
"description": "Descrição C"
}
]
}
};
let authorization = "{{connection_token}}";
// estrutura
try {
const response = await axios({
url: endpoint,
method: method,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + authorization
},
data: payload,
maxBodyLength: Infinity
});
return response.data;
} catch (error) {
return "Algo deu errado: " + error.message;
}
N8N Copie o código e cole em qualquer ponto do seu fluxo no N8N para adicionar o nó.
{
"meta": {
"instanceId": "9fa9daca05c0090113cca7c701b0ce40a3a913034a045b3177740db7d5f7726e"
},
"nodes": [
{
"parameters": {
"method": "POST",
"url": "=https://{{ $item("0").$node["Credenciais"].json["backend_url"] }}/api/messages/sendList",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "={{ $item("0").$node["Credenciais"].json["token"] }}"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={n "number": "{{ $item("0").$node["Credenciais"].json["celular"] }}",n "openTicket": "1",n "queueId": "16",n "body": "Selecione a melhor opção:",n "optionList": {n "buttonLabel": "Abrir lista de opções",n "options": [n {n "id": "1",n "title": "Título A",n "description": "Descrição A"n },n {n "id": "2",n "title": "Título B",n "description": "Descrição B"n },n {n "id": "3",n "title": "Título C",n "description": "Descrição C"n }n ]n }n}",
"options": {}
},
"id": "9e0daf1f-954c-426b-a2bd-d522fc65e2d1",
"name": "Mensagem de Lista",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1380,
660
]
}
],
"connections": {},
"pinData": {}
}
API Utilize o código em requisições HTTPS com ferramentas como cURL ou bibliotecas de integração.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{BACKEND_URL}/api/messages/sendList',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"number": "554498108792",
"body": "Selecione a melhor opção:",
"optionList": {
"buttonLabel": "Abrir lista de opções",
"options": [
{
"id": "1",
"title": "Título A",
"description": "Descrição A"
},
{
"id": "2",
"title": "Título B",
"description": "Descrição B"
}
]
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer {seutokenaqui}' //Token cadastrado na conexão
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
FLOWBUILDER Insira o código em um bloco de "Http Request / Code" do tipo REQUISIÇÃO.
Os trechos delimitados por {{...}} são placeholders no formato Mustaches e não precisam ser alterados. Eles serão automaticamente substituídos pelos valores correspondentes no momento da execução.
// definir
let endpoint = "https://{{backendURL}}/api/messages/sendList";
let method = "POST";
let payload = {
"number": "{{number}}",
"openTicket": "1",
"queueId": "16",
"body": "Selecione a melhor opção:",
"optionList": {
"buttonLabel": "Abrir lista de opções",
"options": [
{
"id": "1",
"title": "Título A",
"description": "Descrição A"
},
{
"id": "2",
"title": "Título B",
"description": "Descrição B"
},
{
"id": "3",
"title": "Título C",
"description": "Descrição C"
}
]
}
};
let authorization = "{{connection_token}}";
// estrutura
try {
const response = await axios({
url: endpoint,
method: method,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + authorization
},
data: payload,
maxBodyLength: Infinity
});
return response.data;
} catch (error) {
return "Algo deu errado: " + error.message;
}
N8N Copie o código e cole em qualquer ponto do seu fluxo no N8N para adicionar o nó.
{
"meta": {
"instanceId": "9fa9daca05c0090113cca7c701b0ce40a3a913034a045b3177740db7d5f7726e"
},
"nodes": [
{
"parameters": {
"method": "POST",
"url": "=https://{{ $item("0").$node["Credenciais"].json["backend_url"] }}/api/messages/sendList",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "={{ $item("0").$node["Credenciais"].json["token"] }}"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={n "number": "{{ $item("0").$node["Credenciais"].json["celular"] }}",n "openTicket": "1",n "queueId": "16",n "body": "Selecione a melhor opção:",n "optionList": {n "buttonLabel": "Abrir lista de opções",n "options": [n {n "id": "1",n "title": "Título A",n "description": "Descrição A"n },n {n "id": "2",n "title": "Título B",n "description": "Descrição B"n },n {n "id": "3",n "title": "Título C",n "description": "Descrição C"n }n ]n }n}",
"options": {}
},
"id": "9e0daf1f-954c-426b-a2bd-d522fc65e2d1",
"name": "Mensagem de Lista",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1380,
660
]
}
],
"connections": {},
"pinData": {}
}