我想使用 twilio 函数自动更新主处理程序失败 webhook Url,有人可以指导我吗?

问题描述 投票:0回答:2

我使用了以下函数并尝试使用curl运行来自邮递员的HTTP请求,但没有成功

exports.handler = function(context, event, callback) {
    const client = context.getTwilioClient();
    const new_fallback_url = 'http://your_twilio_function_url.com/webhooks/twilio_voice_fallback'; // Replace with your actual Twilio Function URL

    // Fetch all phone numbers and update them
    client.incomingPhoneNumbers.list()
        .then(phoneNumbers => {
            const updates = phoneNumbers.map(number => {
                return client.incomingPhoneNumbers(number.sid)
                    .update({ voiceFallbackUrl: new_fallback_url });
            });
            return Promise.all(updates);
        })
        .then(results => {
            callback(null, `Fallback URL updated for ${results.length} numbers`);
        })
        .catch(error => {
            callback(error);
        });
};

我希望运行代码后我所有的 twilio 号码都会自动更新

javascript twilio twilio-api twilio-twiml
2个回答
0
投票

请附上您的邮递员/ cURL 请求的输出,以便其他人可以看到实际的错误/问题是什么。除此之外,还有一些事情需要记住。

  1. 您部署了该功能吗?
  2. 该功能是否部署为“公共”资产?如果它是“私人”或“受保护”,那么您将在响应中收到 401/403 未经授权的错误。
  3. 看起来您提供的代码可能是人工智能生成的,请确保它满足您的要求并且在语法上对于您所需的应用程序是正确的。

0
投票

谢谢你,我找到了解决方案

© www.soinside.com 2019 - 2024. All rights reserved.