My workflow:
{
“nodes”: [
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4o”,
“mode”: “list”,
“cachedResultName”: “gpt-4o”
},
“options”: {
“temperature”: 0.7
}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
-440,
1300
],
“id”: “c3ce11b0-7a93-4961-b01b-78fd57cf7dc3”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “47QO75bhLHAceAfD”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $(‘Entrada’).item.json.body.phone }}”
},
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.3,
“position”: [
-320,
1260
],
“id”: “c32e719a-493f-4cae-a804-c3debc45fade”,
“name”: “Simple Memory”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “20c3e606-d162-492a-9f69-f797f60e7c82”,
“name”: “Regras”,
“value”: “Regras\nREGRAS específicas que você SEMPRE deve seguir:\nVOCÊ NÃO PODE FORNECER INFORMAÇÕES QUE VOCÊ NÃO TENHA.\nVocê NÃO tem acesso a uma tabela de horários e das consultas, ou seja, VOCÊ NÃO PODE E NÃO É CAPAZ DE VERIFICAR QUAIS HORÁRIOS ESTÃO DISPONÍVEIS.\nNUNCA marcar ou definir um horário ou dia, ao invés diga "Para entrar em contato com um atendente, apenas digite ‘atendente’."\nQuando for informar uma URL, informe EXATAMENTE a URL disponível.\nNUNCA fale dos concorrentes.\nNUNCA fale mal dos funcionários ou da franquia.\nVocê não é capaz de analisar ou enviar fotos e vídeos.”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-700,
1100
],
“id”: “08f4dce8-01d6-4cf5-9a7e-e16a509ced44”,
“name”: “Alimentacao IA”
},
{
“parameters”: {
“content”: “## Mensagem”,
“height”: 220,
“width”: 600
},
“type”: “n8n-nodes-base.stickyNote”,
“typeVersion”: 1,
“position”: [
-2860,
1120
],
“id”: “309c599c-a306-49da-98ed-557174035d3f”,
“name”: “Sticky Note1”
},
{
“parameters”: {
“content”: “## IA”,
“height”: 360,
“width”: 680,
“color”: 3
},
“type”: “n8n-nodes-base.stickyNote”,
“typeVersion”: 1,
“position”: [
-800,
1060
],
“id”: “9b557a08-db5d-4264-a6a0-20f064c59732”,
“name”: “Sticky Note”
},
{
“parameters”: {
“options”: {
“timezone”: “UTC-3”
}
},
“type”: “n8n-nodes-base.dateTime”,
“typeVersion”: 2,
“position”: [
-2160,
1180
],
“id”: “f6ea0165-2554-4c9d-aca5-3905fe31a97c”,
“name”: “Date & Time”
},
{
“parameters”: {
“content”: “## Informaçoes necessarias”,
“height”: 240,
“width”: 220,
“color”: 7
},
“type”: “n8n-nodes-base.stickyNote”,
“typeVersion”: 1,
“position”: [
-2220,
1100
],
“id”: “9eefecdb-47e2-493b-8ce0-f4a5be8d5caf”,
“name”: “Sticky Note6”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “6df45916-e54b-41a4-b64d-5159076a909e”,
“leftValue”: “={{ $(‘Entrada’).item.json.body.audio }}”,
“rightValue”: “”,
“operator”: {
“type”: “object”,
“operation”: “exists”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
-1920,
1160
],
“id”: “8dfd98ef-2ec4-4dd7-880e-3425bd13de67”,
“name”: “Audio”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “6df45916-e54b-41a4-b64d-5159076a909e”,
“leftValue”: “={{ $(‘Entrada’).item.json.body.isGroup }}”,
“rightValue”: “”,
“operator”: {
“type”: “boolean”,
“operation”: “false”,
“singleValue”: true
}
},
{
“id”: “af4d2ca8-1e67-421f-8573-9a96ea515a1c”,
“leftValue”: “={{ $(‘Entrada’).item.json.body.isNewsletter }}”,
“rightValue”: “”,
“operator”: {
“type”: “boolean”,
“operation”: “false”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
-2620,
1180
],
“id”: “3f0a05a4-1781-47d4-be21-169852c739a8”,
“name”: “Grupo ou noticia”
},
{
“parameters”: {
“resource”: “audio”,
“operation”: “transcribe”,
“binaryPropertyName”: “Audio_baixado.ogg”,
“options”: {
“language”: “pt”,
“temperature”: 0
}
},
“type”: “@n8n/n8n-nodes-langchain.openAi”,
“typeVersion”: 1.8,
“position”: [
-1540,
1080
],
“id”: “80ad5521-abf8-4be0-9d7d-716607ddbac9”,
“name”: “ATT”,
“credentials”: {
“openAiApi”: {
“id”: “47QO75bhLHAceAfD”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“content”: “## Mensagem”,
“height”: 400,
“width”: 1120
},
“type”: “n8n-nodes-base.stickyNote”,
“typeVersion”: 1,
“position”: [
-1960,
1040
],
“id”: “cf31d303-85af-4d60-9763-5c9a8118c1c7”,
“name”: “Sticky Note20”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “b05541c6-3b23-4fbd-8c59-6658b1969480”,
“name”: “mensagem”,
“value”: “={{$json["text"]}}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-1360,
1080
],
“id”: “97897651-0eb3-4123-b4cc-443e0ae7cf22”,
“name”: “Mudar nome audio”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “b05541c6-3b23-4fbd-8c59-6658b1969480”,
“name”: “mensagem”,
“value”: “={{ $(‘Entrada’).item.json.body.text.message }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-1540,
1260
],
“id”: “5ef2440b-7dfb-4fdb-a437-3f5ec3b1627f”,
“name”: “Mudar nome texto”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “b05541c6-3b23-4fbd-8c59-6658b1969480”,
“name”: “Mensagem_usuario”,
“value”: “={{$json["mensagem"]}}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-1160,
1180
],
“id”: “7f6699d5-bd29-4f85-858b-7f78807e9530”,
“name”: “Mensagem cliente”
},
{
“parameters”: {
“url”: “={{ $(‘Entrada’).item.json.body.audio.audioUrl }}”,
“options”: {
“response”: {
“response”: {
“responseFormat”: “file”,
“outputPropertyName”: “Audio_baixado.ogg”
}
}
}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-1720,
1080
],
“id”: “9b3275c3-46ab-4972-93b3-97986d6240f5”,
“name”: “Baixar audio”
},
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.z-api.io/instances/3DF83D50E924600B89114AF752FBD4C9/token/3A57FD1E57D5401D0D8D9FD0/send-text”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Client-Token”,
“value”: “F10d45f245fb04fff98954cbc06cc5a73S”
}
]
},
“sendBody”: true,
“bodyParameters”: {
“parameters”: [
{
“name”: “phone”,
“value”: “={{ $(‘Entrada’).item.json.body.phone }}”
},
{
“name”: “message”,
“value”: “=DIVA:\n\n{{ $(‘IA resposta’).item.json.output }}”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-60,
1100
],
“id”: “4c00da03-97e0-4b38-a27c-06b80e3e45c8”,
“name”: “Envia resposta da IA”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $(‘Mensagem cliente’).item.json}}”,
“options”: {
“systemMessage”: “=# Nome do paciente: {{ $(‘Entrada’).item.json.body.senderName }}\n\n# Regras e modo de agir: {{ $json.Regras }}\n\n# Para saber a data e hora atual: {{ $(‘Date & Time’).item.json.currentDate }}, sempre verifique a data e hora para informar se a clínica está aberta.”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.8,
“position”: [
-420,
1100
],
“id”: “6947214f-9a9d-4151-9229-c2de647ca493”,
“name”: “IA resposta”
},
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “cfcd14e1-9610-4fac-b8d1-b9f9836a7cda”,
“options”: {}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2,
“position”: [
-2820,
1180
],
“id”: “04ba641b-ad8d-4cd8-aaa7-200fb7e341d3”,
“name”: “Entrada”,
“webhookId”: “cfcd14e1-9610-4fac-b8d1-b9f9836a7cda”
}
],
“connections”: {
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “IA resposta”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “IA resposta”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“Alimentacao IA”: {
“main”: [
[
{
“node”: “IA resposta”,
“type”: “main”,
“index”: 0
}
]
]
},
“Date & Time”: {
“main”: [
[
{
“node”: “Audio”,
“type”: “main”,
“index”: 0
}
]
]
},
“Audio”: {
“main”: [
[
{
“node”: “Baixar audio”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Mudar nome texto”,
“type”: “main”,
“index”: 0
}
]
]
},
“Grupo ou noticia”: {
“main”: [
[
{
“node”: “Date & Time”,
“type”: “main”,
“index”: 0
}
]
]
},
“ATT”: {
“main”: [
[
{
“node”: “Mudar nome audio”,
“type”: “main”,
“index”: 0
}
]
]
},
“Mudar nome audio”: {
“main”: [
[
{
“node”: “Mensagem cliente”,
“type”: “main”,
“index”: 0
}
]
]
},
“Mudar nome texto”: {
“main”: [
[
{
“node”: “Mensagem cliente”,
“type”: “main”,
“index”: 0
}
]
]
},
“Mensagem cliente”: {
“main”: [
[
{
“node”: “Alimentacao IA”,
“type”: “main”,
“index”: 0
}
]
]
},
“Baixar audio”: {
“main”: [
[
{
“node”: “ATT”,
“type”: “main”,
“index”: 0
}
]
]
},
“Envia resposta da IA”: {
“main”: [
]
},
“IA resposta”: {
“main”: [
[
{
“node”: “Envia resposta da IA”,
“type”: “main”,
“index”: 0
}
]
]
},
“Entrada”: {
“main”: [
[
{
“node”: “Grupo ou noticia”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “830499f171848f15a469f0e9f9a863419688d34cef2f92af12f26fd8a2674645”
}
}