breezy
breezy2y ago

How do I write {last_response} to a DOC file?

I have a unique situation where I would like to write the last response from the bot to a DOC file. I have tried: 1. In Voiceflow using a button to call a new URL (PHP file) and have that PHP file create the DOC file and then write to it, but I lose all of the output formatting when I pass the {last_response} to the PHP file. 2. Using a button to call javascript and have javascript create the DOC file and then write to it, but I can't import modules into the Voiceflow javascript so I can't get it to work. 3. Embedded the bot on a PHP page and then added the javascript to create the DOC file and then write to it to that PHP page, but I can't get the {last_resposne} to the javascript. I've looked around for solutions, should I try using "PUT" and write the {last_response} to a database and set up a script that will pull the data from the database and create the DOC file? It feels like that is adding extra steps and that there is a more concise solution, but I'm a newb and unsure of which approach to pursue/implement. Thanks for any advice/direction you can provide.
3 Replies
Tico | Voiceflow Assistant
To write the {last_response} from the bot to a DOC file, you might consider a different approach since direct methods you've tried have limitations. Here's a suggestion based on the capabilities within Voiceflow: - Utilize the JavaScript step in Voiceflow to access and parse the lastevent variable, which stores responses from custom actions. This allows you to manipulate or format the response data before sending it to an external service. - Since direct JavaScript file creation and module imports are limited within Voiceflow, you could send the formatted {last_response} to an external server-side script (e.g., PHP or Node.js) via an API request. This script would then be responsible for creating and writing to the DOC file. - To maintain formatting, ensure that the data passed to your server-side script is properly encoded and that your script handles the decoding and formatting correctly before writing to the DOC file. This method leverages Voiceflow's ability to interact with external APIs and services, allowing for more flexibility in handling the response data. Remember, the key is to format and prepare the data within Voiceflow using JavaScript before sending it out. For more details on working with JavaScript and API calls in Voiceflow, you might find these resources helpful: - Voiceflow JavaScript Step Documentation - Voiceflow API Integration Documentation
breezy
breezyOP2y ago
Thank you so much for your response. I'm new enough to not understand everything you wrote, but most of it makes sense, I will get to work on it and learn as I go. I really appreciate the response, it helps a lot to have a direction.
NiKo | Voiceflow
What is your use case, why a doc file instead of a service like Airtable or your own DB?

Did you find this page helpful?