"Webhook Sending All Lead Data Instead of Defined Payload (WhatsApp Integration)
Collapse
X
-
Dear yuri,
Thank you so much for helping me resolve the WhatsApp template issue in EspoCRM. I really appreciate your time and support!
👍 1 -
Hi Aswathi,
You can add a script action before the Send HTTP Request action to prepare the phone number and store it in a variable. Then, use that variable in the payload with a placeholder $$.
The code so you could copy:
Code:$phone = null; if (phoneNumber) { $phone = phoneNumber; $phone = string\replace($phone, ' ', ''); $phone = string\replace($phone, '-', ''); }Leave a comment:
-
When a new Lead is created, a BPM (Business Process Management) workflow sends a WhatsApp message via a webhook. The Lead’s phone number (stored in the phoneNumber field) may contain spaces, which can cause the WhatsApp API call to fail. The solution is to strip out all whitespace from the phone number within the workflow before triggering the webhook.... what is the solution
Leave a comment:
-
The workflow should not send all lead data. It's likely you have the Webhook configured and running in parallel. You need to disable (or remove) this Webhook and focus only on the Workflow.
The workflow's Send HTTP Request should be suffice to send a proper API request to 360dialog.
Please check whether your workflow is executed at all. On the workflow detail view, check the Log panel in the bottom. Do you have any records there? Each record corresponds to a workflow rule run. When you create a Lead, there should be a log record added immediately.
👍 1Leave a comment:
-
I am sending requests to the WhatsApp API server.I have a WhatsApp Business account with 360dialog as the API provider and have created templates for this number. In EspoCRM, I want to trigger a WhatsApp template message to the corresponding lead's phone number when a new lead is created. but instead of sending the defined payload, it is sending all lead data. How can I fix this?
I have corrected the header format in the workflow, but it is not working as expected. Are there any other ways to integrate EspoCRM with WhatsApp besides using workflows?Leave a comment:
-
I understand that you have configured both Webhook and Workflow in Espo. You can disable the Webhook (Administration > Webhooks).
The Workflow can send HTTP requests with arbitrary header and JSON payload. Do you have the workflow rule triggered? There should Log messages on the Workflow detail view in the bottom.
I'm not sure about WhatsApp. Do you want to send requests to the WhatsApp API or to something else? The log you provided, where it's from? Is it your server where you are sending requests to?
Maybe somebody with experience could chime in.👍 1Leave a comment:
-
I have corrected the header format as per your provided structure and I am using EspoCRM version 8.4.1. I have also enabled debug mode, but the log files do not show any errors. Despite following all these steps, the API is still not triggering, and the same error is appearing in the webhook logs.
30|testdemo-webhook | Incoming webhook11: [{"id":"67dd0fabbfd6d2108","name":"sada sd","deleted":false,"salutationName":"Mr.","firs tN ame":"sada","lastName":"sd","status":"New","addre s sStreet":"dsadsd","addressCity":null,"addressState ":"sd","addressCountry":null,"addressPostalCod e":n ull,"phoneNumber":"+91811399324","doNotCall":false ,"createdAt":"2025-03-21 07:05:15","modifiedAt":"2025-03-21 07:05:15","targetListIsOptedOut":false,"cLeadId":" L00061","cGender":"Male","emailAddressIsOptedOut": false,"emailAddressIsInvalid":false,"phoneNumberIs OptedOut":false,"phoneNumberIsInvalid":false,"phon eNumberData":[{"phoneNumber":"+91811399324","primary":true,"t ype ":"Mobile","optOut":false,"invalid":false}],"createdById":"673072295f932699c","assignedUse rId ":null,"teamsIds":[],"isFollowed":false}]
30|testdemo-webhook | Error: TypeError: Cannot read properties of undefined (reading '0')
insted of actual output
30|testdemo-webhook | Incoming webhook11: {"object":"whatsapp_business_account","entry":[{"id":"116428374850793","changes":[{"value":{"messaging_product":"whatsapp","metad ata ":{"display_phone_number":"914842881790","phon e_nu mber_id":"108181739026718"},"statuses":[{"id":"wamid.HBgMOTE4MDg5NTkwNzkxFQIAERgSNEZBRj dCR kQ4Nzg5Q0JGMzFEAA==","status":"sent","timestamp":" 1741856599","recipient_id":"918089590791","convers ation":{"id":"71d9be93976b1fca1284bb8de511734b","e xpiration_timestamp":"1741943040","origin":{"type" :"utility"}},"pricing":{"billable":true,"pricin g_m odel":"CBP","category":"utility"}}]},"field":"messages"}]}]}
30|testdemo-webhook | hasContacts false
30|testdemo-webhook | desiredObject {
30|testdemo-webhook | statuses: [
30|testdemo-webhook | {
30|testdemo-webhook | id: 'wamid.HBgMOTE4MDg5NTkwNzkxFQIAERgSNEZBRjdCRkQ4Nzg 5Q0JGMzFEAA==',
30|testdemo-webhook | status: 'sent',
30|testdemo-webhook | timestamp: '1741856599',
30|testdemo-webhook | recipient_id: '918089590001',
30|testdemo-webhook | conversation: [Object],
30|testdemo-webhook | pricing: [Object]
30|testdemo-webhook | }
30|testdemo-webhook | ]
30|testdemo-webhook | }
30|testdemo-webhook | Incoming webhook11: {"object":"whatsapp_business_account","entry":[{"id":"116428374850793","changes":[{"value":{"messaging_product":"whatsapp","metad ata ":{"display_phone_number":"914842881790","phon e_nu mber_id":"108181739026718"},"statuses":[{"id":"wamid.HBgMOTE4MDg5NTkwNzkxFQIAERgSNEZBRj dCR kQ4Nzg5Q0JGMzFEAA==","status":"delivered","timesta mp":"1741856601","recipient_id":"918089500001"," co nversation":{"id":"71d9be93976b1fca1284bb8de511734 b","origin":{"type":"utility"}},"pricing":{"bil lab le":true,"pricing_model":"CBP","category":"utili ty "}}]},"field":"messages"}]}]}
30|testdemo-webhook | hasContacts false
30|testdemo-webhook | desiredObject {
30|testdemo-webhook | statuses: [
30|testdemo-webhook | {
30|testdemo-webhook | id: 'wamid.HBgMOTE4MDg5NTkwNzkxFQIAERgSNEZBRjdCRkQ4Nzg 5Q0JGMzFEAA==',
30|testdemo-webhook | status: 'delivered',
30|testdemo-webhook | timestamp: '1741856601',
30|testdemo-webhook | recipient_id: '918089590791',
30|testdemo-webhook | conversation: [Object],
30|testdemo-webhook | pricing: [Object]
30|testdemo-webhook | }
30|testdemo-webhook | ]
30|testdemo-webhook | }
Is it possible to send WhatsApp messages using EspoCRM workflow? Do I need to add any extra steps for this? Can you please help me integrate WhatsApp with EspoCRM?
Leave a comment:
-
Also, for debugging, I recommend enabling a debug mode for the log and check the log file. Don't forget to disable the debug mode afterward.Leave a comment:
-
I think you have a mistake in your header. You have two headers, should be one.
It has to be like this:
BTW. As of v9.0 you can use application secrets to store API KEYs. A secret placeholder can be used in the header: {#secrets.name}
After creating a secret named 'MY_API_KEY' (Administration > App Secrets), specify it in the Send HTTP Request action:
Leave a comment:
-
I am using the workflow with a URL, header format, and payload. However, when a lead is created, the lead data, including the lead name, address, phone number, and other details, is passed via the webhook instead of the specified workflow URL and payload.1 PhotoLeave a comment:
-
Do you use the Webhook functionality or Workflow > Send HTTP Request? For the latter, you just define the needed payload. For the Webhook, there's not such an ability.👍 1Leave a comment:
-
"Webhook Sending All Lead Data Instead of Defined Payload (WhatsApp Integration)
I am trying to configure an EspoCRM Workflow to trigger a WhatsApp message when a new Lead is created. The Lead entity already has a phoneNumber field, and I want to send a POST request to our API with a specific payload.
However, instead of sending only the defined payload, the workflow is sending all lead data, including extra fields like firstName, lastName, email, etc.
url;--https://your-whatsapp-api.com/v1/tmessage
payload:
{
"to": "+919700000002",
"namespace": "c6372e57_603a_4b72_baa8_cb41841772ed",
"name": "missed_call",
"language": {
"policy": "deterministic",
"code": "en"
}
}
Tags: None

Leave a comment: