0
votes

I´m developing a chatbot using Twilio Studio and at some point, I need to collect the data inputs from the clients that talk to my bot, and then post it into an airtable base. I don´t have much coding skills, so my guide was this Dabble Lab tutorial: https://www.youtube.com/watch?v=xjt9YhNFrno

However, the Twilio function proposed in the video isn´t working. Here is the code:

exports.handler = function(context, event, callback) {

let member = {
    name : event.name,
    email : event.email,
    date : Date.now()
};

var Airtable = require('airtable');
var base = new Airtable({apiKey: context.AIRTABLE_API_KEY}).base('appISrkMnNdL65Lzj');

base('Members').create(member, function(err, record) {
    if (err) { console.error(err); return; }
    console.log(record.getId());
    callback(null, member);
});

};

When I try to make a POST request via Postman, this is what happens in my Twilio Console And this is the capture of Postman response As I´m using Twilio Studio Flow for developing the chatbot, I guess I could use the HTTP Request Widget but I really don´t know how to configure it. The columns in my base are: Id - name - email - date

Any idea how can I solve this?

1

1 Answers

0
votes

There are a couple of good Twilio/Airtable blogs recently posted. It looks like you are getting an error back but your error condition isn't calling the callback and thus the timeout.

Could it be some issue is with the Airtable field types not liking the type of the data you are posting, in particular the date.

Maybe you need something like this instead?

const today = new Date();
const date = `${(today.getMonth()+1)}/${today.getDate()}/${today.getFullYear()}`;

Writing to Airtable from your Twilio app

Using Airtable as a database for your Twilio app