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": "SP \u00b7 18 \u00b7 Primera Visita \u2014 Formularios 24h/2h antes",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "primera-visita-forms",
"responseMode": "lastNode",
"options": {}
},
"id": "sp18-0001",
"name": "Webhook \u00b7 PV \u2014 programar formularios",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
240,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={ \"ok\": true }"
},
"id": "sp18-0002",
"name": "Responder OK",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
460,
500
]
},
{
"parameters": {
"jsCode": "const d = $input.first().json;\nconst now = new Date();\nconst citaFecha = d.fechaTimestamp ? new Date(d.fechaTimestamp) : new Date();\nconst diffMs = citaFecha - now;\nconst diffHoras = diffMs / (1000 * 60 * 60);\nconst esperarMs = diffHoras > 24\n ? diffMs - 24 * 60 * 60 * 1000\n : Math.max(0, diffMs - 2 * 60 * 60 * 1000);\nconst esMenos24h = diffHoras <= 24;\nreturn [{ json: { ...d, esperarMs: Math.max(0, esperarMs), esMenos24h } }];"
},
"id": "sp18-0003",
"name": "Calcular cu\u00e1ndo enviar",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
460,
300
]
},
{
"parameters": {
"resume": "timeInterval",
"unit": "milliseconds",
"amount": "={{ $json.esperarMs }}"
},
"id": "sp18-0004",
"name": "Esperar hasta 24h antes (\u00f3 2h si urgente)",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
680,
300
]
},
{
"parameters": {
"jsCode": "const d = $input.first().json;\nconst esMenor = d.esMenor || false;\nconst telefonoDestino = d.telefonoTutor || d.telefono;\nconst linkCuestionario = `${$vars.CUESTIONARIO_BASE_URL}?token=${d.token || d.idPac}`;\nconst cuando = d.esMenos24h ? 'hoy' : 'ma\u00f1ana';\nconst texto = esMenor\n ? `\ud83d\udc76 Hola ${d.nombreTutor || d.nombre}, ${cuando} es la primera cita de *${d.nombre}* a las ${d.horaStr}h.\\n\\nCompleta los documentos antes de la visita (5 min):\\n\ud83d\udccb Cuestionario de salud + LOPD: ${linkCuestionario}\\n\\n\u23f0 El enlace expira 1h despu\u00e9s de la cita.`\n : `\ud83d\udc4b Hola ${d.nombre}, ${cuando} tienes tu primera cita en ${$vars.CLINICA_NOMBRE} a las *${d.horaStr}h*.\\n\\nPara prepararla completa estos documentos (3 min):\\n\ud83d\udccb Cuestionario de salud: ${linkCuestionario}\\n\ud83d\udd12 Incluye firma de privacidad (LOPD)\\n\\n\u23f0 El enlace expira 1h despu\u00e9s de tu cita.`;\nreturn [{ json: { ...d, mensaje: texto, telefonoDestino, linkCuestionario } }];"
},
"id": "sp18-0005",
"name": "Preparar mensaje formularios",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
900,
300
]
},
{
"parameters": {
"method": "POST",
"url": "={{ $vars.EVOLUTION_URL }}/message/sendText/{{ $vars.EVOLUTION_INSTANCE }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $vars.EVOLUTION_API_KEY }}"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"number\": \"34{{ $json.telefonoDestino.replace(/[^0-9]/g,'').replace(/^34/,'') }}@s.whatsapp.net\",\n \"text\": \"{{ $json.mensaje }}\"\n}"
},
"id": "sp18-0006",
"name": "WhatsApp \u00b7 Formularios PV",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
1120,
300
]
}
],
"connections": {
"Webhook \u00b7 PV \u2014 programar formularios": {
"main": [
[
{
"node": "Calcular cu\u00e1ndo enviar",
"type": "main",
"index": 0
},
{
"node": "Responder OK",
"type": "main",
"index": 0
}
]
]
},
"Calcular cu\u00e1ndo enviar": {
"main": [
[
{
"node": "Esperar hasta 24h antes (\u00f3 2h si urgente)",
"type": "main",
"index": 0
}
]
]
},
"Esperar hasta 24h antes (\u00f3 2h si urgente)": {
"main": [
[
{
"node": "Preparar mensaje formularios",
"type": "main",
"index": 0
}
]
]
},
"Preparar mensaje formularios": {
"main": [
[
{
"node": "WhatsApp \u00b7 Formularios PV",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"id": "sp-pv-24h-forms-018",
"_nota": "POST /webhook/primera-visita-forms con: { nombre, telefono, horaStr, fechaTimestamp (ISO), idPac/token, esMenor?, nombreTutor?, telefonoTutor? }"
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
SP · 18 · Primera Visita — Formularios 24h/2h antes. Uses httpRequest. Webhook trigger; 6 nodes.
Source: https://github.com/Manzanedodelgado/SmilePro-Studio/blob/7a67a0777c43ab52ee492a48d0c1616b905b49a2/n8n-workflows/18-pv-24h-forms.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 n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di
This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .
eek-Go v2 (Batch-Then-Review). Uses httpRequest. Webhook trigger; 75 nodes.
This workflow receives webhook requests from a content calendar and uses the X API v2 to publish text posts, threads, image/video posts, and polls, as well as delete existing posts and run a credentia
This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c