like-gold
like-gold16mo ago

trigger a flow from an external API

From what I understand, i can make a POST request to the following endpoint https://api.voiceflow.com/v2/versions/%7BversionID%7D/export, is that right? And how to i fetch it from voiceflow and trigger a flow?
1 Reply
Tico | Voiceflow Assistant
Yes, you're correct. You can make a POST request to the endpoint https://api.voiceflow.com/v2/versions/{versionID}/export to retrieve your Voiceflow project files. However, this endpoint is used to export your Voiceflow project as a .vf file, which contains information about your project details, blocks, and diagrams. It doesn't directly trigger a flow. To trigger a flow from an external API, you would typically use the Dialog API. The Dialog API is designed to manage the conversation state at runtime and is used for production use cases, custom interface prototypes, and more. To start a conversation, you would send a launch request. To pass a user's response, you would send a text request. For NLU matching, you would directly send an intent request. Here's a simplified example of a verbose response body:
{
"state": {
"stack": [
{
"programID": "home flow",
"nodeID": "yes no choice node"
}
],
"storage": {},
"variables": {
"pizzatype": "pepperoni"
}
},
"trace": [
{
"type": "speak",
"payload": {
"type": "message",
"message": "fries with that?"
}
},
{
"type": "visual",
"payload": {
"image": "https://voiceflow.com/pizza.png"
}
}
]
}
{
"state": {
"stack": [
{
"programID": "home flow",
"nodeID": "yes no choice node"
}
],
"storage": {},
"variables": {
"pizzatype": "pepperoni"
}
},
"trace": [
{
"type": "speak",
"payload": {
"type": "message",
"message": "fries with that?"
}
},
{
"type": "visual",
"payload": {
"image": "https://voiceflow.com/pizza.png"
}
}
]
}
Please note that to use the Dialog API, you need to have a versionID, which is a unique identifier for a specific version of your Voiceflow project. You can get the versionID from the URL when you're editing your project in Voiceflow. Also, remember that it's not recommended to use sensitive or private information in the userID, such as emails, real names, or phone numbers. For more detailed information, you can check out the Voiceflow API reference on the Voiceflow documentation site.

Did you find this page helpful?