wise-white
wise-white2y ago

Voiceflow API parameters

Hello people - do any of you know how to pass variable calues (like name and email address entered by the user) into an API block raw body? I assume I have to set the parameters and then call the keys from the code, but that doesn't work. This is the code I have that works with static values: { "sendWelcomeEmail": true, "firstName": "Dan", "tags": [ "Mila" ], "identifiers": [ { "type": "email", "consent": { "source": "Mila" }, "channels": { "email": { "status": "subscribed" } }, "id": "dan+26@spacedroid.co.uk" } ], "country": "United Kingdom", "countryCode": "GB" } But when I set the parameters and use this it does not: { "sendWelcomeEmail": true, "firstName": first_name, "tags": [ "Mila" ], "identifiers": [ { "type": "email", "consent": { "source": "Mila" }, "channels": { "email": { "status": "subscribed" } }, "id": email_address } ], "country": "United Kingdom", "countryCode": "GB" } Thank you so much! Cheers, Dan
2 Replies
Tico | Voiceflow Assistant
To pass variable values into an API block raw body in Voiceflow, you need to use the correct syntax for referencing variables. In your case, you're trying to pass the variables first_name and email_address into the API block. However, you're not referencing them correctly in your JSON body. In Voiceflow, variables are referenced using the {variable} syntax. So, your JSON body should look like this:
{
"sendWelcomeEmail": true,
"firstName": "{first_name}",
"tags": [
"Mila"
],
"identifiers": [
{
"type": "email",
"consent": {
"source": "Mila"
},
"channels": {
"email": {
"status": "subscribed"
}
},
"id": "{email_address}"
}
],
"country": "United Kingdom",
"countryCode": "GB"
}
{
"sendWelcomeEmail": true,
"firstName": "{first_name}",
"tags": [
"Mila"
],
"identifiers": [
{
"type": "email",
"consent": {
"source": "Mila"
},
"channels": {
"email": {
"status": "subscribed"
}
},
"id": "{email_address}"
}
],
"country": "United Kingdom",
"countryCode": "GB"
}
Please note that the variable names are case-sensitive and should match exactly with the ones you've defined in your project. Sources: - Using Personas to Simulate Different User Types in User Testing - API - Update State Variables
wise-white
wise-whiteOP2y ago
Thank you, that worked!

Did you find this page helpful?