如何检查Twilio电话会议是否有>1人?



我需要知道如何检查现有的会议桥,以查看当前有多少用户在通话。如果这是不可能的,仅仅能够看到会议是否开放可能会达到同样的效果。

解释:我有一个twilio流程,它创建了一个硬编码值为"123"的会议。如果用户呼叫进来,而会议中没有人,我希望它将用户置于会议中,并继续进行流程的其余部分。但是,如果2个或更多用户已经在会议中,并且第三个用户呼叫进来,我希望将第三个用户放置在会议中,并且不执行任何其他操作。

// This is your new function. To start, set the name and path on the left.
exports.handler = function(context, event, callback) {
// Here's an example of setting up some TWiML to respond to with this function
const client = context.getTwilioClient();
let syncServiceSid = 'mySyncSid';

var participants
participants = client.conferences('12345') 
.participants 
.list({limit: 20})
.then(participants => participants.forEach(p => console.log(JSON.stringify(participants))));
// This callback is what is returned in response to this function being invoked.
// It's really important! E.g. you might respond with TWiML here for a voice or SMS response.
// Or you might return JSON data to a studio flow. Don't forget it!
return callback(null, participants);
};

我需要知道如何检查现有的会议桥,以查看当前有多少用户在通话。

您可以使用Conference Participant Resource来检索参与者的数量,在Python中它看起来像这样(其中CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX是您的会议名称):

from twilio.rest import Client
client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
participants = client.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') 
.participants 
.list(limit=20)

文档中有其他编程语言的代码示例。

最新更新