【问题标题】:Twilio Error 11200- HTTP retrieval failure: Attempt to retrieve media failed, while trying to Trigger a Twilio Studio Flow Execution via Rest APITwilio 错误 11200 - HTTP 检索失败:尝试检索媒体失败,同时尝试通过 Rest API 触发 Twilio Studio 流执行
【发布时间】:2021-10-10 07:02:34
【问题描述】:

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

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

Twilio 错误日志:

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

邮递员测试结果:

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

工作室流程在第一个实例中调用的函数是:

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 twilio-api postman-testcase


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

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

    Studio Flow 不应该调用该函数,该函数使用此代码创建一个执行:

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

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

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

    Studio Flow

    【讨论】:

    • 1. Postman 的第二个测试结果抛出一个 AssertionError,因为它期望的时间是
    • 2.还尝试直接调用 Twilio 函数而不是调用 REST API 来执行 Studio Flow,但这对我来说也没有帮助。
    • 你还没有解决问题吗?我注意到在您的一个屏幕截图中,您显示了未能发送的出站消息。你有correct geographic permissions for sending SMS吗?
    • 不,不是。 SMS 的地理权限没问题,因为它适用于我的其他项目,但不是这个。
    • 对于那些失败的出站消息,如果您将鼠标悬停在失败旁边的i 上,或者点击进入消息,是否有更多关于消息失败原因的信息?
    猜你喜欢
    • 2020-11-08
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 2019-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多