Trying to make a dynamic send email node from webhook trigger

Hi everyone, I try to make a dynamic send email node by noting down “{{ $json.email_receiver }}” as receiver. This is because the trigger is from a webhook, Custom GPT to be precise.
I want to have multiple users to be able to send different emails through automation. Error I get is “output not defined” but the webhook did get triggered successfully.

Error message: no recipients defined

Workflow:

{
“nodes”: [
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “incident-webhook”,
“options”: {}
},
“name”: “Webhook”,
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 1,
“position”: [
-640,
-100
],
“id”: “350e9703-2d09-44c5-8879-52bde18c66a4”,
“webhookId”: “df52cd65-a64c-4486-942f-b4755fdcd9a9”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“name”: “onderwerp”,
“value”: “={{ $json.onderwerp }}”,
“type”: “string”,
“id”: “b2fd1816-dd9c-4671-90fe-d0a1a3f5eb37”
},
{
“name”: “email_tekst”,
“value”: “={{ $json.email_tekst }}”,
“type”: “string”,
“id”: “c6526f1b-3e9d-4169-9602-d68576fde78e”
},
{
“name”: “email_ontvanger”,
“value”: “={{ $json.email_ontvanger }}”,
“type”: “string”,
“id”: “1e587fa9-32b6-4a51-8e8a-5981311ac443”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“name”: “Edit Fields”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-520,
-300
],
“id”: “683cc864-5ec2-4fcd-9c19-7b964942e11d”
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “={{ $json.email_ontvanger }}”,
“ccEmail”: “=”,
“subject”: “={{ $json.onderwerp }}”,
“text”: “={{ $json.email_tekst }}”,
“options”: {}
},
“name”: “Stuur E-mail”,
“type”: “n8n-nodes-base.emailSend”,
“typeVersion”: 1,
“position”: [
-340,
-120
],
“id”: “4bfca818-801e-4d6c-b247-35fcb498cba6”,
“credentials”: {
“smtp”: {
“id”: “Y715NLjR5o0ri6PS”,
“name”: “SMTP account”
}
}
},
{
“parameters”: {
“amount”: 20,
“unit”: “seconds”
},
“name”: “Wacht 20 seconden”,
“type”: “n8n-nodes-base.wait”,
“typeVersion”: 1,
“position”: [
-40,
-120
],
“id”: “4c19a994-88af-4002-ba44-d2f61ec96cd3”,
“webhookId”: “30bcc5c8-79bf-4bdc-be09-ce29e584e2bf”
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “={{ $json.email_ontvanger }}”,
“subject”: “Herinnering: Incidentmelding AP”,
“text”: “Dit is een herinnering dat er 72 uur zijn verstreken sinds een incidentmelding. Controleer of melding aan de Autoriteit Persoonsgegevens is gedaan.”,
“options”: {}
},
“name”: “Reminder Email”,
“type”: “n8n-nodes-base.emailSend”,
“typeVersion”: 1,
“position”: [
120,
-300
],
“id”: “4d5f1fc1-2028-48eb-adbb-d1c5ef3a1443”,
“credentials”: {
“smtp”: {
“id”: “Y715NLjR5o0ri6PS”,
“name”: “SMTP account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “27bd24f6-6721-400f-8e1f-02c916194656”,
“name”: “email_ontvanger”,
“value”: “={{$(‘Webhook’).first().json.email_ontvanger}}”,
“type”: “string”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-200,
-300
],
“id”: “560008b3-f864-4dbc-9dd6-55a0777c0d65”,
“name”: “Edit Fields1”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “d0b3ea3e-3177-4987-93d0-f5d57d0670e8”,
“name”: “status”,
“value”: “success”,
“type”: “string”
},
{
“id”: “b944d247-df50-413a-b37a-88063c40057f”,
“name”: “message”,
“value”: “De melding is succesvol verzonden en de herinneringsmail is verstuurd.”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
280,
-300
],
“id”: “d7df836c-8c87-488a-b8db-833c776f7d78”,
“name”: “Edit Fields2”
}
],
“connections”: {
“Webhook”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields”: {
“main”: [
[
{
“node”: “Stuur E-mail”,
“type”: “main”,
“index”: 0
}
]
]
},
“Stuur E-mail”: {
“main”: [
[
{
“node”: “Edit Fields1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Wacht 20 seconden”: {
“main”: [
[
{
“node”: “Reminder Email”,
“type”: “main”,
“index”: 0
}
]
]
},
“Reminder Email”: {
“main”: [
[
{
“node”: “Edit Fields2”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields1”: {
“main”: [
[
{
“node”: “Wacht 20 seconden”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“Webhook”: [
{
“email_ontvanger”: “[email protected]”,
“onderwerp”: “Melding van datalek – INC-20250608-001”,
“email_tekst”: “Beste FG,\n\nEr is een mogelijk datalek gemeld. Hieronder volgt de samenvatting:\n\nMeldingssamenvatting – Mogelijk datalek\n• Incidentnummer: INC-20250608-001\n• Datum incident: 7 juni 2025\n• Beschrijving: Verlies van documenten\n• Ontdekt op: 8 juni via medewerker\n• Externe partijen: Geen\n• Persoonsgegevens: NAW, e-mail\n• Betrokkenen: Klanten\n• Aantal personen: 15\n• Gevolgen: Kans op onbedoelde toegang\n• Oorzaak: Dossier op OV achtergelaten\n• Maatregelen: Nieuwe werkinstructies\n• Toelichting: Interne evaluatie gestart\n• Melder: Ting Wong – [email protected]\n\nMet vriendelijke groet,\nPrivacy Guide GPT”,
“incident”: {
“incident_id”: “INC-20250608-001”,
“incidentdatum”: “2025-06-07”,
“ontdekkingsdatum”: “2025-06-08”,
“ontdekkingswijze”: “via medewerker”,
“incidentbeschrijving”: “Verlies van documenten”,
“oorzaak”: “Dossier op OV achtergelaten”,
“externe_partijen”: “Geen”,
“betrokkenen”: “Klanten”,
“persoonsgegevens”: “NAW, e-mail”,
“aantal_personen”: 15,
“gevolgen”: “Kans op onbedoelde toegang”,
“maatregelen”: “Nieuwe werkinstructies”,
“toelichting”: “Interne evaluatie gestart”,
“melder_naam”: “Ting Wong”,
“melder_email”: “[email protected]
}
}
],
“Edit Fields2”: [
{
“status”: “success”,
“message”: “Herinneringsmail is verstuurd”
}
]
},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “9b2dd64bb4712eebc18adfb5221ac2317bdb01e01dbda6f60d7915f7c357c484”
}
}

Hey @Ting hope all is well, welcome to the community.

Would you like to embed your workflow here for us to take a look?

Hi Jabbson, yes here it is!

{
“nodes”: [
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “incident-webhook”,
“options”: {}
},
“name”: “Webhook”,
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 1,
“position”: [
-640,
-100
],
“id”: “350e9703-2d09-44c5-8879-52bde18c66a4”,
“webhookId”: “df52cd65-a64c-4486-942f-b4755fdcd9a9”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“name”: “onderwerp”,
“value”: “={{ $json.onderwerp }}”,
“type”: “string”,
“id”: “b2fd1816-dd9c-4671-90fe-d0a1a3f5eb37”
},
{
“name”: “email_tekst”,
“value”: “={{ $json.email_tekst }}”,
“type”: “string”,
“id”: “c6526f1b-3e9d-4169-9602-d68576fde78e”
},
{
“name”: “email_ontvanger”,
“value”: “={{ $json.email_ontvanger }}”,
“type”: “string”,
“id”: “1e587fa9-32b6-4a51-8e8a-5981311ac443”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“name”: “Edit Fields”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-520,
-300
],
“id”: “683cc864-5ec2-4fcd-9c19-7b964942e11d”
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “={{ $json.email_ontvanger }}”,
“ccEmail”: “=”,
“subject”: “={{ $json.onderwerp }}”,
“text”: “={{ $json.email_tekst }}”,
“options”: {}
},
“name”: “Stuur E-mail”,
“type”: “n8n-nodes-base.emailSend”,
“typeVersion”: 1,
“position”: [
-340,
-120
],
“id”: “4bfca818-801e-4d6c-b247-35fcb498cba6”,
“credentials”: {
“smtp”: {
“id”: “Y715NLjR5o0ri6PS”,
“name”: “SMTP account”
}
}
},
{
“parameters”: {
“amount”: 20,
“unit”: “seconds”
},
“name”: “Wacht 20 seconden”,
“type”: “n8n-nodes-base.wait”,
“typeVersion”: 1,
“position”: [
-40,
-120
],
“id”: “4c19a994-88af-4002-ba44-d2f61ec96cd3”,
“webhookId”: “30bcc5c8-79bf-4bdc-be09-ce29e584e2bf”
},
{
“parameters”: {
“fromEmail”: “[email protected]”,
“toEmail”: “={{ $json.email_ontvanger }}”,
“subject”: “Herinnering: Incidentmelding AP”,
“text”: “Dit is een herinnering dat er 72 uur zijn verstreken sinds een incidentmelding. Controleer of melding aan de Autoriteit Persoonsgegevens is gedaan.”,
“options”: {}
},
“name”: “Reminder Email”,
“type”: “n8n-nodes-base.emailSend”,
“typeVersion”: 1,
“position”: [
120,
-300
],
“id”: “4d5f1fc1-2028-48eb-adbb-d1c5ef3a1443”,
“credentials”: {
“smtp”: {
“id”: “Y715NLjR5o0ri6PS”,
“name”: “SMTP account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “27bd24f6-6721-400f-8e1f-02c916194656”,
“name”: “email_ontvanger”,
“value”: “={{$(‘Webhook’).first().json.email_ontvanger}}”,
“type”: “string”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-200,
-300
],
“id”: “560008b3-f864-4dbc-9dd6-55a0777c0d65”,
“name”: “Edit Fields1”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “d0b3ea3e-3177-4987-93d0-f5d57d0670e8”,
“name”: “status”,
“value”: “success”,
“type”: “string”
},
{
“id”: “b944d247-df50-413a-b37a-88063c40057f”,
“name”: “message”,
“value”: “De melding is succesvol verzonden en de herinneringsmail is verstuurd.”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
280,
-300
],
“id”: “d7df836c-8c87-488a-b8db-833c776f7d78”,
“name”: “Edit Fields2”
}
],
“connections”: {
“Webhook”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields”: {
“main”: [
[
{
“node”: “Stuur E-mail”,
“type”: “main”,
“index”: 0
}
]
]
},
“Stuur E-mail”: {
“main”: [
[
{
“node”: “Edit Fields1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Wacht 20 seconden”: {
“main”: [
[
{
“node”: “Reminder Email”,
“type”: “main”,
“index”: 0
}
]
]
},
“Reminder Email”: {
“main”: [
[
{
“node”: “Edit Fields2”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields1”: {
“main”: [
[
{
“node”: “Wacht 20 seconden”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“Webhook”: [
{
“email_ontvanger”: “[email protected]”,
“onderwerp”: “Melding van datalek – INC-20250608-001”,
“email_tekst”: “Beste FG,\n\nEr is een mogelijk datalek gemeld. Hieronder volgt de samenvatting:\n\nMeldingssamenvatting – Mogelijk datalek\n• Incidentnummer: INC-20250608-001\n• Datum incident: 7 juni 2025\n• Beschrijving: Verlies van documenten\n• Ontdekt op: 8 juni via medewerker\n• Externe partijen: Geen\n• Persoonsgegevens: NAW, e-mail\n• Betrokkenen: Klanten\n• Aantal personen: 15\n• Gevolgen: Kans op onbedoelde toegang\n• Oorzaak: Dossier op OV achtergelaten\n• Maatregelen: Nieuwe werkinstructies\n• Toelichting: Interne evaluatie gestart\n• Melder: Ting Wong – [email protected]\n\nMet vriendelijke groet,\nPrivacy Guide GPT”,
“incident”: {
“incident_id”: “INC-20250608-001”,
“incidentdatum”: “2025-06-07”,
“ontdekkingsdatum”: “2025-06-08”,
“ontdekkingswijze”: “via medewerker”,
“incidentbeschrijving”: “Verlies van documenten”,
“oorzaak”: “Dossier op OV achtergelaten”,
“externe_partijen”: “Geen”,
“betrokkenen”: “Klanten”,
“persoonsgegevens”: “NAW, e-mail”,
“aantal_personen”: 15,
“gevolgen”: “Kans op onbedoelde toegang”,
“maatregelen”: “Nieuwe werkinstructies”,
“toelichting”: “Interne evaluatie gestart”,
“melder_naam”: “Ting Wong”,
“melder_email”: “[email protected]
}
}
],
“Edit Fields2”: [
{
“status”: “success”,
“message”: “Herinneringsmail is verstuurd”
}
]
},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “9b2dd64bb4712eebc18adfb5221ac2317bdb01e01dbda6f60d7915f7c357c484”
}
}

See if setting the value of
{{ $('Webhook').item.json.email_ontvanger }}
in the “Edit Fields1” node helps

Aha just that node?
I just tried and failed, same for changing the other nodes :frowning:
Same error, workflow stops at send e-mail…

Don’t know my friend, I changed that webhook reference and the email to mine and received 2 email 20 seconds apart.

Yes, that works if you just execute the workflow.
But the trigger must come from the custom GPT, through actions. As I tell the GPT to send an email to [email protected] or another time, to [email protected] I would like n8n to automatically change that…