How Can I Reference a Parameter Passed By a Tool i...
# support
s
My goal is that whenever the lead says they want to enable DND/be removed from our contacts list during the call, the tool called "EnableDNDWorkflow" will be triggered and which triggers a workflow I made in GHL to enable DND for that contact. The tool has the following description: If the lead wants to opt-out or enable DND, fire this function to trigger a workflow in GoHighLevel named "Lead Opts Out During Vapi Call" And has a string parameter called "LeadsPhone" with the following description: The lead's phone number In GHL, I have a workflow that's responsible with enabling DND for the lead. It has "Inbound Webhook" as the trigger linked to the tool. So that when the tool fires, it will trigger the workflow in GHL. The connection is fine. The tool is able to trigger the workflow in GHL. The problem is, the workflow is unable to identify the lead who wants to enable DND. That's why I have the "LeadsPhone". So that the workflow can search for a phone number in the CRM that matches with "LeadsPhone". But I can't seem to access the "LeadsPhone" parameter within GHL even though it's being passed by the tool.
v
Based on the information I found, try using the
metadata
parameter when configuring your Vapi tool to ensure the phone number is properly passed to GHL:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: agentId,
  metadata: { LeadsPhone: phoneNumber },
  config: buttonConfig,
});
In GHL, you may need to check the webhook payload structure to determine how to reference this parameter in your workflow. Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1339495894801711186)
Based on the information I found, try using the
metadata
parameter when configuring your Vapi tool to ensure the phone number is properly passed to GHL:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: agentId,
  metadata: { LeadsPhone: phoneNumber },
  config: buttonConfig,
});
In GHL, you may need to check the webhook payload structure to determine how to reference this parameter in your workflow. Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1339495894801711186)
s
@User I think that my Vapi tool is passing the number properly. Because upon examining the mapping reference ni GHL, I see that the "LeadsPhone" has a phone number inside it. Also, I tried checking the webhook payload structure like you asked. And I can see that the parameter is being passed. But for some reason, I can't access the parameter inside the "Create Contact" action inside the workflow. https://cdn.discordapp.com/attachments/1369752996245799023/1369755859717984256/image.png?ex=681d040d&is=681bb28d&hm=e10f0e9c1db4933d2f53f156ccf9d926cba7ad245a37fc9e6a59feb37595a43e&
v
Message marked as helpful by @sibyorself! 🎉
s
@Vapi Support Bot I think that my Vapi tool is passing the number properly. Because upon examining the mapping reference ni GHL, I see that the "LeadsPhone" has a phone number inside it. Also, I tried checking the webhook payload structure like you asked. And I can see that the parameter is being passed. But for some reason, I can't access the parameter inside the "Create Contact" action inside the workflow. https://cdn.discordapp.com/attachments/1369752996245799023/1369761075641319495/image.png?ex=681d08e9&is=681bb769&hm=98c811446c646fd0af6268ea4bbf0e5c91f6e326a2a5fc79ca3cf8da08fefb95&
v
I need to understand how you're trying to access the parameter in GHL. Could you share more details about how you're attempting to reference the "LeadsPhone" parameter within the "Create Contact" action in your GHL workflow? For example, are you using a specific syntax like
{{webhook.LeadsPhone}}
,
{{data.LeadsPhone}}
, or something else? This would help me identify where the issue might be in accessing the parameter.
I need to understand how you're trying to access the parameter in GHL. Could you share more details about how you're attempting to reference the "LeadsPhone" parameter within the "Create Contact" action in your GHL workflow? For example, are you using a specific syntax like
{{webhook.LeadsPhone}}
,
{{data.LeadsPhone}}
, or something else? This would help me identify where the issue might be in accessing the parameter.
s
@Vapi Support Bot Not exactly like a specific syntax. But more like selecting from a dropdown. GHL lists all the possible parameters I'm able to access from the webhook connection but the "LeadsPhone" isn't on that dropdown.
v
Try deleting your current assistant and creating a new one with the metadata parameter to pass the phone number:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: agentId,
  metadata: { LeadsPhone: phoneNumber },
  config: buttonConfig,
});
This approach allows you to pass customer information that can be retrieved later using the API, potentially bypassing the dropdown limitation in GHL. Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1341746304744685599)
Try deleting your current assistant and creating a new one with the metadata parameter to pass the phone number:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: agentId,
  metadata: { LeadsPhone: phoneNumber },
  config: buttonConfig,
});
This approach allows you to pass customer information that can be retrieved later using the API, potentially bypassing the dropdown limitation in GHL. Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1341746304744685599)
Could you check exactly where in the webhook payload structure the "LeadsPhone" parameter appears? Based on your image description, it seems to be nested inside
toolCalls[0].arguments
. GHL might be looking for parameters at the root level of the payload rather than nested within the arguments object. Have you tried examining other successful webhook integrations with GHL to see how their parameters are structured in comparison to yours? Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1339495894801711186)
Could you check exactly where in the webhook payload structure the "LeadsPhone" parameter appears? Based on your image description, it seems to be nested inside
toolCalls[0].arguments
. GHL might be looking for parameters at the root level of the payload rather than nested within the arguments object. Have you tried examining other successful webhook integrations with GHL to see how their parameters are structured in comparison to yours? Source: - [Discord Channel Discussion](https://discord.com/channels/1211482211119796234/1339495894801711186)
s
@Vapi Support Bot Looking at other webhooks, almost all of the parameters are appearing. Even the nested ones.
v
Try manually mapping the parameter by using a custom field in the GHL workflow. Add a JavaScript step before the "Create Contact" action to extract the value:
Copy code
javascript
// Extract the phone number from the nested structure
const leadsPhone = payload.message.toolCalls[0].arguments.LeadsPhone;

// Store it in a custom variable that will appear in the dropdown
workflow.setVariable('extractedLeadsPhone', leadsPhone);
Then use
extractedLeadsPhone
in your Create Contact action. Source: - [Understanding GoHighLevel webhook payload structure](https://discord.com/channels/1211482211119796234/1321375442644762625)
Try manually mapping the parameter by using a custom field in the GHL workflow. Add a JavaScript step before the "Create Contact" action to extract the value:
Copy code
javascript
// Extract the phone number from the nested structure
const leadsPhone = payload.message.toolCalls[0].arguments.LeadsPhone;

// Store it in a custom variable that will appear in the dropdown
workflow.setVariable('extractedLeadsPhone', leadsPhone);
Then use
extractedLeadsPhone
in your Create Contact action. Source: - [Understanding GoHighLevel webhook payload structure](https://discord.com/channels/1211482211119796234/1321375442644762625)
k
\[
Hey! To help track down this issue, could you share: - The call ID - When exactly this happened (the timestamp) - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
4 Views