I’m working with Twilio Autopilot and need help with data retrieval. My bot first uses a Collect task to get a date input from users (like Feb 15, 2019). After getting this date, I want to query my Airtable base to find the matching record and then tell the user what’s happening on that date (something like “on Feb 15 the Downtown Cinema is showing this film, the Uptown Theater has…”).
I’ve got the Airtable lookup working, but I’m stuck on how to take the response data and turn it into variables I can use in my bot’s reply.
exports.handler = function(context, event, callback) {
var Airtable = require('airtable');
var database = new Airtable({apiKey:
'myapikey'}).base('mybasekey');
database('MovieSchedule').find('recXYZ123ABC456DEF', function(error, result) {
if (error) { console.error(error); return; }
console.log(result);
});
}
The response from Airtable looks like this:
{
"id": "recXYZ123ABC456DEF",
"fields": {
"ShowDate": "2019-02-15",
"Downtown Cinema": "Spider-Man",
"Uptown Theater": "Batman"
},
"createdTime": "2019-02-15T18:30:22.000Z"
}