Reputation: 99
I am building a conversational voice bot with Twilio and Node.js. Whenever a call ends, I need to send collected data(collected in Twilio autopilot Memory object) to a database. If the user completes the entire question-answer session with the bot, I am able to send the data to a DB. But if the user hangs up the call in between, the execution of functions stops completely. To handle this, I am triggering a function(called callEnd.js) execution on call-end using 'CALL STATUS CHANGES' in the Twilio console. But the event object provided in callEnd parameter does not contain the Memory object. How do I handle this?
My objective is to push partially collected/full collected data to DB.
Upvotes: 0
Views: 300
Reputation: 73075
Twilio developer evangelist here.
If your questions are distributed over several functions and you want to permanently store the collected data no matter how far through the conversation the user gets, then I recommend that you store the answers each time you receive a webhook from Autopilot updating your database with everything that is in event.Memory
at that point.
That way your DB will collect the data and it doesn't matter how far the call gets, it will always have all the answers that the user provided.
Upvotes: 0