繁体   English   中英

Twilio 错误 11200- HTTP 检索失败:尝试检索媒体失败,同时尝试通过 Rest API 触发 Twilio Studio 流程执行

[英]Twilio Error 11200- HTTP retrieval failure: Attempt to retrieve media failed, while trying to Trigger a Twilio Studio Flow Execution via Rest API

我正在尝试构建此预约管理系统,以使用 Twilio+ Airtable + Postman 安排疫苗接种预约。([链接到以下博客]) 2

为了通过 Rest API 触发 Twilio studio flow 并从我的 Twilio 号码获取我的个人号码上的可编程消息,我通过提供包含真实 flow_sid 和其他详细信息的流程的 URL 发出此 POST 请求,但每次发出post请求遇到以下错误:

Twilio 错误日志:

  1. (错误:11200) HTTP 检索失败尝试检索此 URL 的内容时失败。

错误

Postman 测试结果:

  1. 响应时间小于1000ms | AssertionError:预期 2315 低于 1000

错误

studio flow 在第一个实例中调用的 function 是:

 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); }); };

工作室流程

Twilio 开发者布道师在这里。

我认为,根据您的问题,您正在通过直接向 Flow 发出 API 请求来创建 Studio Flow Execution。 但是,您包含的 Function 旨在从 Airtable 收集数据后提出该请求。

Studio Flow 不应调用 function,function 使用此代码创建执行:

     client.studio.v1.flows('Vaccine-Reminder').executions.create(
       {
         to: '+91xxxxxxxxxx',
         from: '+12xxxxxxxxxx',
         parameters: JSON.stringify(params_list)
       }
     )

Postman 测试结果具有误导性。 API 在不到 1000 毫秒内没有响应这一事实意味着它可能会更快,但 201 响应表明它至少是成功的。

不要使用 Postman 创建 Studio 执行,而是尝试使用它来调用您的 Twilio Function 如果有帮助,请告诉我。

工作室流程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM