【发布时间】:2018-03-31 21:58:34
【问题描述】:
在 Heroku 上运行 Node/Twilio 应用程序。我想将一个参与者放入一个会议,然后获取该参与者所在会议的信息。
以下是我返回将参与者放入会议的 Twiml 的方式:
//response parameter is a VoiceResponse
function addConferenceToResponse(response,params){
baseUrl=APP_URL+'ivr/conferenceControl';
console.log("addConferenceToResponse: baseUrl "+baseUrl);
//serializes the parameter array and adds it the the GET request
url=addArrayToGetRequest(baseUrl,params,"params");
const dial = response.dial({
action: url,
method: 'GET',
hangupOnStar: true
});
dial.conference(params.conferenceName,{
statusCallbackEvent:'start end join leave',
statusCallback:APP_URL+'ivr/statusChangeConference',
statusCallbackMethod:'GET',
waitUrl:waitUrl,
waitMethod:'GET'
});
return response.toString();
}
按照模型here,我有一个返回会议状态和FriendlyNames列表的函数:
function listConferences(){
client.conferences.each((conference) => {
console.log("list conferences: " + conference.status);
console.log("list conferences: " + conference.friendly_name);
})
}
我在会议的 StatusCallback 中这样调用:
router.get('/statusChangeConference',(req,res)=>{
status=req.query.StatusCallbackEvent;
if (status=="participant-join"){
handler.listConferences();
}
sendValue=doSomethingToGetASendValue();
if (sendValue!=null){
res.send(sendValue);
}
});
listConferences() 最终返回数百行:
2018-03-31T21:39:41.734717+00:00 app[web.1]: list conferences: completed
2018-03-31T21:39:41.734769+00:00 app[web.1]: list conferences: undefined
这意味着,我认为,它正在返回所有过去的会议,我猜这些会议现在不再有 FriendlyNames?但当前活动的会议未显示在此列表中。因此,在 Twilio 有机会将会议输入其数据库之前,可能会执行此 StatusCallbackEvent。
如何获取当前活动会议的属性?我正在尝试做的一件事是将所有剩余的会议参与者重定向到另一个 URL,如果他们中的一个人离开的话,如果无法获取当前会议并执行以下操作,这似乎是不可能的:
client.conferences.each(conference=>{
conference.participants.each(participant=>{
client.calls(participant.CallSid).update({
//url redirect stuff here
});
});
});
但如果我无法获得当前活动的会议,我就无法做到这一点。
【问题讨论】:
-
你没有从你的函数中返回任何东西,没有返回语句,这正常吗?
-
@MaieonBrix 函数只打算调用
console.log(),所以没有返回值有关系吗? -
愚蠢的我,我没有专注抱歉
标签: node.js heroku twilio twilio-api twilio-twiml