Twilio developer evangelist here.
To record the call without the <Record>
TwiML verb, you could
- Serve with the AP connect verb
<Response> <Connect> <Autopilot>
...
- Use the Call SID received in the response to that and use the call recording controls API to start recording the call.
Alternatively, you could use the Moment
package in a Twilio function that is redirected from an Autopilot task.
For the task you want to record user input for, your Autopilot task code may look like this:
{
"actions": [
{
"collect": {
"name": "your-task-name",
"questions": [
{
"question": {
"say": "What's your first name?"
},
"name": "first_name",
"type": "Twilio.FIRST_NAME"
},
{
"question": {
"say": "How many people would you like the reservation to be for?"
},
"name": "number",
"type": "Twilio.NUMBER"
}
],
"on_complete": {
"redirect": "https://your-function-url.twil.io/your-function-name"
}
}
}
]
}
After redirecting to the Twilio Function, you could write some Node.js code with the Moment module that may look like this:
exports.handler = function(context, event, callback) {
const moment = require('moment');
let responseObject = {};
let memory = JSON.parse(event.Memory);
let first_name = memory.twilio.collected_data.your-task-name.answers.first_name.answer || 'to whom it may concern';
let number = memory.twilio.collected_data.your-task-name.answers.number.answer;
let message = "Ok " + first_name + "You said your group is of size " + number + "Thank you for booking with us";
ResponseObject = {
"actions":[
{ "say": { "speech": message } }
]};
callback(null, responseObject);
}
The code above saves the user's answers to each question your Autopilot assistant asks, expecting different types of responses. These Built-in Field Types include numbers, yes or no answers, dates, times, first names, last names, emails, months, US states, countries, cities, days of the week, currencies, languages, and more. You can also keep track of the question the Autopilot assistant asks in each Autopilot task.
There's more details in this Deep Table tutorial and this Facebook Messenger bot blog post (different communication platform, same code to parse user input.) Hope this helps!