Twilio 拨打电话号码不能用url播放自己的声音mp3

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

我使用 Node v14.19.2 这是我的代码

const accountSid = process.env.ACCOUNT_SID;
    const authToken = process.env.AUTH_TOKEN;
    const client = twilio(accountSid, authToken);

    const callResults = []

    // Use the Twilio API client to initiate the call
    for (let number of phoneNumbers) {
        number = number.toString().trim()
        number = number.startsWith('0') ? number.slice(1) : number
        number = '+66' + number
        const call = await client.calls.create({
            url: 'https://demo.twilio.com/docs/classic.mp3',
            to: number,
            from: process.env.TWILIO_NUMBER, // Twilio phone number from which to make the call
            timeout: 120
        });
        callResults.push(call)
    }

当我接电话时,我总是得到相同的语音响应(我认为这是默认语音) 如何修复它以使用 url 语音响应

解决我的问题或找出解决方案

node.js twilio twilio-api twilio-twiml
1个回答
0
投票

为了播放您声音的另一个 mp3,您必须在请求中指定一个新的 URL 参数

我建议将您的 mp3 文件上传到 Twilio Assets。当您执行此操作时,您将获得该资产的 URL,然后您可以将其传递到您的请求中。

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