End of call report collection can’t be converted t...
# support
m
I am sending my data structure request to a webhook in make. I am sending 4 variables so I think that makes it a collection and it appears to be output as an array When I am attempting use this in my Ghl connector I get the error in attached screenshot telling me the collection can’t be converted to text What can I do in vapi to send the structured data out as simple text and not a collection ? https://cdn.discordapp.com/attachments/1305050950708494416/1305050951190843392/Screenshot_2024-11-09_at_19.05.56.png?ex=67319ee9&is=67304d69&hm=91f22e9c5a927a81590f3820a7c25e6814ee0382196c8853be7a55dfa7cd2c50&
v
@MFG To send structured data as simple text from VAPI, you would need to convert the collection of variables into a text string before sending it to the webhook. This typically involves serializing the collection into a JSON string or concatenating the variables into a delimited text string. Here's a general approach you can take: 1. Serialize the collection into a JSON string: - Use a JSON serialization method to convert your collection of variables into a JSON string. This will represent your structured data as text, which can be sent to the webhook. 2. Concatenate variables into a delimited string: - If JSON is not suitable for your use case, you can concatenate the variables into a single string, using a delimiter such as a comma or pipe character to separate the values. Since you're working with VAPI, you would typically perform this conversion in your voice application code before making the webhook request. If you need specific guidance on how to implement this in VAPI, please provide more details about the structure of your data and the code you're using to send the webhook request. If you're unsure how to proceed or need further assistance with the code, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
m
Please help explain how I can achieve this. I am outputting 4 Boolean variables called qualified, unqualified, do not call and call completed
v
@MFG Certainly! To send your four Boolean variables (
qualified
,
unqualified
,
do_not_call
, and
call_completed
) as simple text instead of a collection, you can convert them into a JSON string or a delimited text string. Here's how you can do it: 1. JSON String Method: - Convert the variables into a JSON object and then stringify it. This will turn your structured data into a JSON formatted text string. Example in pseudo-code:
Copy code
javascript
   let data = {
     qualified: true, // or false, depending on the actual value
     unqualified: false,
     do_not_call: true,
     call_completed: false
   };

   let jsonString = JSON.stringify(data);
   // jsonString will be '{"qualified":true,"unqualified":false,"do_not_call":true,"call_completed":false}'
   // You can now send jsonString to your webhook
2. Delimited Text String Method: - Create a string that concatenates the variable names and values, separated by a delimiter such as a comma. Example in pseudo-code:
Copy code
javascript
   let qualified = true; // or false
   let unqualified = false;
   let do_not_call = true;
   let call_completed = false;

   let textString = `qualified=${qualified},unqualified=${unqualified},do_not_call=${do_not_call},call_completed=${call_completed}`;
   // textString will be 'qualified=true,unqualified=false,do_not_call=true,call_completed=false'
   // You can now send textString to your webhook
Choose the method that best fits the expected format of your webhook receiver. If the receiver expects JSON, use the JSON string method. If it expects a plain text string with key-value pairs, use the delimited text string method. If you need to implement this in VAPI, you would typically write a function in your voice application code that performs this conversion before sending the data to the webhook. If you need help with the specific code or have any other questions, please let me know!
m
Where in vapi would I write this code ?
s
Hey @MFG can you share the call id?