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 - Appointment Scheduler",
"active": true,
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "schedule-appointment",
"responseMode": "onReceived"
},
"name": "Webhook Schedule Request",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT d.id, u.name, s.name as specialty, s.price, s.duration FROM doctors d JOIN users u ON d.user_id = u.id JOIN specialties s ON d.specialty_id = s.id WHERE u.active = true AND s.name ILIKE '%{{ $json.specialty }}%' ORDER BY u.name LIMIT 5;"
},
"name": "Find Available Doctors",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
460,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT appointment_date FROM appointments WHERE doctor_id = {{ $json.doctor_id }} AND appointment_date::date = '{{ $json.requested_date }}'::date AND status IN ('SCHEDULED', 'CONFIRMED') ORDER BY appointment_date;"
},
"name": "Check Doctor Schedule",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
680,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO users (name, phone, email, role, created_at) VALUES ('{{ $json.patient_name }}', '{{ $json.phone_number }}', '{{ $json.email || $json.phone_number + '@whatsapp.temp' }}', 'PATIENT', NOW()) ON CONFLICT (phone) DO UPDATE SET name = EXCLUDED.name, email = EXCLUDED.email RETURNING id;"
},
"name": "Find or Create Patient",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
900,
200
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO appointments (patient_id, doctor_id, appointment_date, status, notes, created_at) VALUES ({{ $json.patient_id }}, {{ $json.doctor_id }}, '{{ $json.appointment_datetime }}', 'SCHEDULED', 'Agendado via WhatsApp AI - N8N', NOW()) RETURNING id, appointment_date;"
},
"name": "Create Appointment",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
1120,
300
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"url": "http://host.docker.internal:3000/api/v1/webhooks/whatsapp",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "to",
"value": "{{ $json.phone_number }}"
},
{
"name": "message",
"value": "\u2705 Consulta agendada com sucesso!\\n\\n\ud83d\udcc5 Data: {{ $json.appointment_date }}\\n\ud83d\udc68\u200d\u2695\ufe0f M\u00e9dico: {{ $json.doctor_name }}\\n\ud83c\udfe5 Especialidade: {{ $json.specialty }}\\n\\n\ud83d\udccb Detalhes enviados por SMS/email.\\n\\nObrigado por escolher a EO Cl\u00ednica! \ud83c\udfe5"
}
]
}
},
"name": "Send Confirmation WhatsApp",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
1340,
300
]
}
],
"connections": {
"Webhook Schedule Request": {
"main": [
[
{
"node": "Find Available Doctors",
"type": "main",
"index": 0
}
]
]
},
"Find Available Doctors": {
"main": [
[
{
"node": "Check Doctor Schedule",
"type": "main",
"index": 0
}
]
]
},
"Check Doctor Schedule": {
"main": [
[
{
"node": "Find or Create Patient",
"type": "main",
"index": 0
}
]
]
},
"Find or Create Patient": {
"main": [
[
{
"node": "Create Appointment",
"type": "main",
"index": 0
}
]
]
},
"Create Appointment": {
"main": [
[
{
"node": "Send Confirmation WhatsApp",
"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 - Appointment Scheduler. Uses postgres, httpRequest. Webhook trigger; 6 nodes.
Source: https://github.com/josivantarcio/jtarcio-clinica/blob/5a32b5aefd7b5b26708a538f33cd13647eac413f/n8n-workflows/workflow2.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.
Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.
Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.
Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.
Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.
Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.