Chatbots (fluxos)
Leia, crie, altere e ative fluxos de chatbot para WhatsApp, Instagram e chat do site. Um fluxo é um grafo de nós (mensagem, pergunta com opções, condição, horário de atendimento, ação, delay, fim…). Leitura exige `chatbots:read`; escrita exige `chatbots:write`.
https://app.syncro.chat/api/v1AuthX-API-Key: crm_SUA_CHAVE_AQUIConceitos importantes
- Envelope versionado. O fluxo trafega num único objeto
envelope—{ syncro_chatbot_flow, schema_version, channel, flow, graph }— o mesmo que oGETdevolve e oPOST/PUTaceita de volta. - Nasce inativo. Fluxos criados pela API começam desativados. Ativar (
PATCH /chatbots/{id}/toggle) faz o bot passar a responder conversas reais — confirme com o usuário antes. - Canal imutável. Depois de criado, o canal do fluxo não muda. Um
PUTcom canal diferente retornachannel_mismatch. PUTsubstitui o grafo inteiro. Faça umGETantes e envie o envelope completo.validate_only: truefaz dry-run (sempre200, comerrors/warnings, sem gravar).- Recursos do plano. Requer a feature
chatbotligada; canalwebsiterequer tambémwebsite_chat.
Listar fluxos
/chatbotschatbots:readPaginado. Aceita filtros por canal, status e busca por nome.
Parâmetros de query
channelstringopcionalwhatsapp, instagram ou websiteis_activebooleanopcionalsearchstringopcionalpageintegeropcionalper_pageintegeropcionalcurl "https://app.syncro.chat/api/v1/chatbots?channel=whatsapp&is_active=true" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true,
"data": [
{
"id": 12,
"name": "Boas-vindas",
"channel": "whatsapp",
"is_active": true,
"is_catch_all": false,
"trigger_type": "keyword",
"trigger_keywords": [
"oi",
"menu"
],
"whatsapp_instance_id": null,
"completions_count": 340,
"updated_at": "2026-07-19T18:00:00-03:00"
}
],
"meta": {
"total": 1,
"per_page": 30,
"current_page": 1,
"last_page": 1,
"has_more": false
}
}Detalhar um fluxo
/chatbots/12chatbots:readDevolve o status do fluxo mais o envelope re-importável.
curl "https://app.syncro.chat/api/v1/chatbots/12" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true,
"data": {
"id": 12,
"is_active": true,
"is_catch_all": false,
"whatsapp_instance_id": null,
"completions_count": 340,
"updated_at": "2026-07-19T18:00:00-03:00",
"envelope": {
"syncro_chatbot_flow": true,
"schema_version": 1,
"channel": "whatsapp",
"flow": {
"name": "Boas-vindas",
"channel": "whatsapp",
"trigger_type": "keyword",
"trigger_keywords": [
"oi",
"menu"
]
},
"graph": {
"nodes": [],
"edges": []
}
}
}
}Criar um fluxo
/chatbotschatbots:writeO fluxo nasce inativo. Use PATCH /chatbots/{id}/toggle para ativá-lo depois.
Parâmetros do body
envelopeobjectobrigatório{ syncro_chatbot_flow, schema_version, channel, flow, graph }whatsapp_instance_idintegeropcionalis_catch_allbooleanopcionalvalidate_onlybooleanopcionalerrors/warnings sem gravarcurl -X POST "https://app.syncro.chat/api/v1/chatbots" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"envelope": {
"syncro_chatbot_flow": true,
"schema_version": 1,
"channel": "whatsapp",
"flow": {
"name": "Boas-vindas",
"channel": "whatsapp",
"trigger_type": "keyword",
"trigger_keywords": [
"oi",
"menu"
]
},
"graph": {
"nodes": [
{
"id": "n1",
"type": "message",
"position": {
"x": 300,
"y": 200
},
"data": {
"text": "Olá! Como posso ajudar?"
}
},
{
"id": "n2",
"type": "end",
"position": {
"x": 600,
"y": 200
},
"data": {}
}
],
"edges": [
{
"id": "e1",
"source": "n1",
"sourceHandle": "default",
"target": "n2"
}
]
}
}
}'Regras do grafo
- Um único nó inicial — exatamente um nó sem aresta de entrada (é o início do fluxo).
- Ramos (opções) usam handles
branch-N(com hífen:branch-0,branch-1…), únicos por nó, e cada aresta de ramo precisa de umsourceHandlecorrespondente. - Limites do runtime: delay de 1 a 30s; botões nativos ≤ 3 (rótulo ≤ 20 caracteres); listas ≤ 10 itens (rótulo ≤ 24, descrição ≤ 72); no máx. 200 nós / 400 arestas; payload ≤ 2 MB.
Alterar um fluxo
/chatbots/12chatbots:writeSubstitui o grafo inteiro. Faça um GET antes e envie o envelope completo.
Parâmetros do body
envelopeobjectobrigatóriovalidate_onlybooleanopcionalerrors/warnings sem gravarO canal é imutável: um PUT com canal diferente do original retorna channel_mismatch.
curl -X PUT "https://app.syncro.chat/api/v1/chatbots/12" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"envelope": {
"syncro_chatbot_flow": true,
"schema_version": 1,
"channel": "whatsapp",
"flow": {
"name": "Boas-vindas",
"channel": "whatsapp",
"trigger_type": "keyword",
"trigger_keywords": [
"oi",
"menu"
]
},
"graph": {
"nodes": [
{
"id": "n1",
"type": "message",
"position": {
"x": 300,
"y": 200
},
"data": {
"text": "Olá! Como posso ajudar?"
}
},
{
"id": "n2",
"type": "end",
"position": {
"x": 600,
"y": 200
},
"data": {}
}
],
"edges": [
{
"id": "e1",
"source": "n1",
"sourceHandle": "default",
"target": "n2"
}
]
}
}
}'Ativar / desativar fluxo
/chatbots/12/togglechatbots:writeEnvie { "is_active": true }. Se is_active estiver ausente, o estado atual é invertido. Ativar faz o bot passar a responder conversas reais.
Parâmetros do body
is_activebooleanopcionalAtivar recheca as features do plano: retorna 403 se faltar chatbot (ou website_chat, no canal website).
curl -X PATCH "https://app.syncro.chat/api/v1/chatbots/12/toggle" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"is_active": true
}'Excluir fluxo
/chatbots/12chatbots:writecurl -X DELETE "https://app.syncro.chat/api/v1/chatbots/12" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true
}Descobrir o que é válido
/chatbots/capabilitieschatbots:readDevolve tipos de nó por canal, subtipos de ação, regras de handle, limites e um envelope de exemplo — é a fonte única do validador. Consulte antes de montar um fluxo.
curl "https://app.syncro.chat/api/v1/chatbots/capabilities" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
Tipos de nó e ações
Tipos de nó (9): message, input, condition, business_hours, action, delay, end, disable_chatbot, cards (só site).
Subtipos de ação (nó action): change_stage, save_variable, close_conversation, send_whatsapp, add_tag, remove_tag, assign_human, assign_random_user, send_webhook, set_custom_field, assign_ai_agent, create_task, enroll_sequence, transfer_conversation, create_lead (site), redirect (site).
Formato de erro
422 com errors: [{ path, code, message }]. Ex.: path: "graph.nodes[3].data.branches[1].handle", code: "invalid_handle".
Códigos comuns: feature_missing, limit_reached, channel_mismatch, no_start_node, multiple_start_nodes, invalid_handle, duplicate_handle, cap_exceeded, fk_not_found, payload_too_large.