我试图建立这个预约管理系统,使用Twilio+ Airtable +邮递员来安排疫苗接种预约。(链接到以下博客)2
为了通过Rest触发Twilio流,并从我的Twilio号码中获取我个人号码上的可编程消息,我通过提供包含真实flow_sid和其他详细信息的流的URL来请求这个帖子,但是每次发出POST请求时都会遇到以下错误:
Twilio错误日志:

邮递员测试结果:

studio流在第一个实例中调用的函数是:
const airtable = require("airtable");
exports.handler = function (context, event, callback) {
const base = new airtable({apiKey: context.AIRTABLE_API_KEY}).base(context.AIRTABLE_BASE_ID);
const client = context.getTwilioClient();
let paramsMap = new Map();
base("appointments")
.select()
.all()
.then((records) => {
const sendingMessages = records.map((record) => {
if (record.get('Appointment_Status') === "pending"){
paramsMap['name'] = record.get('Name');
paramsMap['appointment_date'] = record.get('Date');
paramsMap['appointment_time'] = record.get('Appointment_Time');
paramsMap['airtable_record_id'] = record.getId();
paramsMap['appt_id'] = record.get('ID');
}
});
return Promise.all(sendingMessages);
})
.then(() => {
if (paramsMap['name'] === undefined) //No appointments in system
{
console.log("No appointments in system");
callback(null, "From studio function");
}
params_list = {
"appointment_date": paramsMap['appointment_date'],
"appointment_time": paramsMap['appointment_time'],
"provider_name":"Owl Health",
"patient_name": paramsMap['name'],
"airtable_record_id": paramsMap['airtable_record_id'],
"appt_id": paramsMap['appt_id']
};
client.studio.v1.flows('Vaccine-Reminder').executions.create(
{
to: '+91xxxxxxxxxx',
from: '+12xxxxxxxxxx',
parameters: JSON.stringify(params_list)
}
)
.then(function(execution) {
console.log("Execution Id:" + execution.sid);
callback(null, "Message sent via studio function");
})
.catch(err => callback(err));
})
.catch((err) => {
console.log("Airtable error");
callback(err);
});
};

发布于 2021-08-09 00:40:54
两位开发人员在这里传道。
从您的问题中,我认为您是通过直接向流发出API请求来创建Studio流执行的。但是,您所包含的函数的目的是在从Airtable收集数据之后提出该请求。
Studio流不应该调用该函数,该函数使用以下代码创建一个执行:
client.studio.v1.flows('Vaccine-Reminder').executions.create(
{
to: '+91xxxxxxxxxx',
from: '+12xxxxxxxxxx',
parameters: JSON.stringify(params_list)
}
)邮递员的测试结果有误导性。API没有在1000 at以下响应,这意味着它可能会更快,但201响应表明它至少是成功的。
不要使用Postman来创建Studio执行程序,而是尝试使用它来调用Twilio函数,并让我知道这是否有帮助。
https://stackoverflow.com/questions/68663715
复制相似问题