在Twilio语音中将与会者添加到会议后,访问被拒绝

时间:2019-11-19 16:25:42

标签: node.js twilio twilio-voice

我的api中有2个端点,一个端点创建Voice conference,另一个端点将参与者添加到conference

第一个是以下内容,并且可以正常工作。

module.exports.call = function (req, res) {
    let name = 'conf_' + req.body.CallSid

    const twiml = new twilio.twiml.VoiceResponse()
    const dial = twiml.dial({ callerId: req.configuration.twilio.callerId })

    dial.conference(
        {
            endConferenceOnExit: true,
            statusCallbackEvent: 'join',
            statusCallback: `/api/phone/call/${req.body.CallSid}/add-participant/${encodeURIComponent(req.body.phone)}`
        },
        name
    )

    res.set({
        'Content-Type': 'application/xml',
        'Cache-Control': 'public, max-age=0',
    })

    res.send(twiml.toString())
}

如您所见,statusCallback URL指向下面的控制器,该控制器应将参加者添加到会议中。

module.exports.addParticipant = function (req, res) {

    console.log('addParticipant', req.params)

    if (req.body.CallSid === req.params.sid) {
        /* the agent joined, we now call the phone number and add it to the conference */
        conference = client.conferences('conf_' + req.params.sid)
        console.log('conference', conference)
        client
            .conferences('conf_' + req.params.sid)
            .participants.create({
                to: '+34XXXXXXXXX',
                from: req.configuration.twilio.callerId,
                earlyMedia: true,
                endConferenceOnExit: true
            }).then(participant => {
                res.status(200).end()
            })
            .catch(error => {
                console.error(error)
                res.status(500).end()
            })

    } else {
        res.status(200).end()
    }

}

但是,出现以下错误:

[RestException [Error]: Access Denied] {
  status: 403,
  message: 'Access Denied',
  code: 20006,
  moreInfo: 'https://www.twilio.com/docs/errors/20006',
  detail: undefined
}

我已为该数字国家/地区启用了地理权限,但仍然没有成功。

我想念什么?

1 个答案:

答案 0 :(得分:1)

您确定要在您的帐户中启用座席会议吗?

语音会议设置 https://www.twilio.com/console/voice/conferences/settings