This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "WhatsApp AI - Message Processor",
"active": true,
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "whatsapp-incoming",
"responseMode": "onReceived",
"responseCode": 200,
"responseData": "allEntries"
},
"name": "Webhook WhatsApp",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "phone_number",
"value": "={{ $json.entry && $json.entry[0] && $json.entry[0].changes && $json.entry[0].changes[0] && $json.entry[0].changes[0].value && $json.entry[0].changes[0].value.contacts && $json.entry[0].changes[0].value.contacts[0] ? $json.entry[0].changes[0].value.contacts[0].wa_id : 'unknown' }}"
},
{
"name": "message_text",
"value": "={{ $json.entry && $json.entry[0] && $json.entry[0].changes && $json.entry[0].changes[0] && $json.entry[0].changes[0].value && $json.entry[0].changes[0].value.messages && $json.entry[0].changes[0].value.messages[0] && $json.entry[0].changes[0].value.messages[0].text ? $json.entry[0].changes[0].value.messages[0].text.body : '' }}"
},
{
"name": "message_type",
"value": "={{ $json.entry && $json.entry[0] && $json.entry[0].changes && $json.entry[0].changes[0] && $json.entry[0].changes[0].value && $json.entry[0].changes[0].value.messages && $json.entry[0].changes[0].value.messages[0] ? $json.entry[0].changes[0].value.messages[0].type : 'unknown' }}"
},
{
"name": "timestamp",
"value": "={{ new Date().toISOString() }}"
}
]
}
},
"name": "Extract Message Data",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
460,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.message_text }}",
"operation": "isNotEmpty"
}
]
}
},
"name": "Check Valid Message",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
680,
300
]
},
{
"parameters": {
"url": "http://host.docker.internal:3000/api/v1/ai/process-message",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer {{ $node['Get Auth Token'].json['token'] }}"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "phone_number",
"value": "={{ $json.phone_number }}"
},
{
"name": "message",
"value": "={{ $json.message_text }}"
},
{
"name": "message_type",
"value": "={{ $json.message_type }}"
},
{
"name": "source",
"value": "whatsapp_n8n"
}
]
}
},
"name": "Process with EO Cl\u00ednica AI",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
900,
200
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO whatsapp_messages (phone_number, message_text, message_type, direction, processed_at, ai_response) VALUES ('{{ $json.phone_number }}', '{{ $json.message_text }}', '{{ $json.message_type }}', 'incoming', NOW(), '{{ $node['Process with EO Cl\u00ednica AI'].json['response'] }}') RETURNING id;"
},
"name": "Log Message to DB",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
1120,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Webhook WhatsApp": {
"main": [
[
{
"node": "Extract Message Data",
"type": "main",
"index": 0
}
]
]
},
"Extract Message Data": {
"main": [
[
{
"node": "Check Valid Message",
"type": "main",
"index": 0
}
]
]
},
"Check Valid Message": {
"main": [
[
{
"node": "Process with EO Cl\u00ednica AI",
"type": "main",
"index": 0
}
],
[]
]
},
"Process with EO Cl\u00ednica AI": {
"main": [
[
{
"node": "Log Message to DB",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
postgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
WhatsApp AI - Message Processor. Uses httpRequest, postgres. Webhook trigger; 5 nodes.
Source: https://github.com/josivantarcio/jtarcio-clinica/blob/5a32b5aefd7b5b26708a538f33cd13647eac413f/n8n-workflows/workflow1.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates end-to-end research analysis by coordinating multiple AI models—including NVIDIA NIM (Llama), OpenAI GPT-4, and Claude to analyze uploaded documents, extract insights, and gene
QA Platform — Jira Story to Test Workflow. Uses jiraTrigger, postgres, httpRequest, slack. Webhook trigger; 20 nodes.
Kids & Teen Networking - Atendimento e Agendamento WhatsApp. Uses httpRequest, postgres. Webhook trigger; 20 nodes.
Automação de Chargeback - Contestação SaaS. Uses httpRequest, postgres, emailSend, slack. Webhook trigger; 14 nodes.
Advanced Workflow with Branching and Error Handling. Uses emailSend, httpRequest, postgres, slack. Webhook trigger; 12 nodes.