I’m working on a chatbot project using Twilio Studio, and I need to gather data from users interacting with my bot to save it in an Airtable base. My coding knowledge is limited, and I was following a tutorial from Dabble Lab. However, the Twilio function shown in the tutorial is not functioning correctly. Here’s my code snippet:
exports.handler = function(context, event, callback) {
let userDetails = {
fullName: event.name,
userEmail: event.email,
submissionDate: Date.now()
};
const Airtable = require('airtable');
const airtableBase = new Airtable({apiKey: context.AIRTABLE_API_KEY}).base('appISrkMnNdL65Lzj');
airtableBase('Members').create(userDetails, function(err, record) {
if (err) { console.error(err); return; }
console.log(record.getId());
callback(null, userDetails);
});
}
When sending a POST request using Postman, I encounter issues displayed in my Twilio Console. Additionally, I’m unsure how to utilize the HTTP Request Widget in Twilio Studio for this purpose. My Airtable columns include: Id, fullName, userEmail, submissionDate. Can anyone provide guidance on how to address this problem?