基于Bot Framework+Graph API的视频通话及屏幕共享问题排查
背景
我正在开发一款可发起两人通话的机器人,当前已实现User A与User B的通话发起功能:机器人初始化通话后加入会话,两位用户会收到Bot_Name的来电提醒,双方接听后可通过机器人发起的通话连接。
问题
双方加入通话后,参与者列表中无主持人,User A和User B均无法开启视频或屏幕共享;若User A接听时选择视频通话,其视频仅对User B可见,User B的视频无法被A看到,且屏幕共享始终不可用。
代码/函数
参考微软文档「Create service based VoIP calls」实现如下代码:
async makeCall(data) { let targetMembers: callTarget[] = [ { '@odata.type': '#microsoft.graph.invitationParticipantInfo', identity: { '@odata.type': '#microsoft.graph.identitySet', user: { '@odata.type': '#microsoft.graph.identity', displayName: data.userA.name, id: data.userA.aadObjectId, tenantId: data.userA.tenantId } } }, { '@odata.type': '#microsoft.graph.invitationParticipantInfo', identity: { '@odata.type': '#microsoft.graph.identitySet', user: { '@odata.type': '#microsoft.graph.identity', displayName: data.userB.name, id: data.userB.aadObjectId, tenantId: data.userB.tenantId } } } ] const call = { '@odata.type': '#microsoft.graph.call', direction: 'outgoing', subject: data.topic, callbackUri: config.callBackUri + "/call-callback", source: { '@odata.type': '#microsoft.graph.participantInfo', identity: { '@odata.type': '#microsoft.graph.identitySet', application: { '@odata.type': '#microsoft.graph.identity', displayName: 'App for Teams', id: 'xxxxxx-xxxx-xxxx-xxxx-botIdxxxxb23' } } }, targets: targetMembers, requestedModalities: ['audio', 'video', 'videoBasedScreenSharing'], mediaConfig: { '@odata.type': '#microsoft.graph.serviceHostedMediaConfig', removeFromDefaultAudioGroup: false }, tenantId: 'xxxxxx-xxxx-xxxx-xxxx-xxxxxtenentId' }; try { const response = await this.graphClient.api('/communications/calls').post(call); } catch (error) { console.log(error); } }
通过上述方法可成功初始化通话,但视频和屏幕共享功能存在异常。
已尝试方案
- 在requested modalities和active modalities中添加
['audio', 'video', 'videoBasedScreenSharing'] - 将用户设为共同组织者
- 实现调用
changeScreenSharingRole接口的函数(参考相关文档)
async enableSharing(callId) { const changeScreenSharingRole = { role: 'sharer' }; try { const response = await this.graphClient.api(`/communications/calls/${callId}/changeScreenSharingRole`).post(changeScreenSharingRole); console.log(response); } catch (error) { console.log(error); // Handle any errors that occur during the API call } }
调用该函数时触发500错误(代码9999),错误信息如下:
GraphError: Encountered exception during changing screen sharing role. at new GraphError (E:\CallngBot\Deployment\CallngBot\bot\node_modules\@microsoft\microsoft-graph-client\src\GraphError.ts:63:3) at Function.GraphErrorHandler.constructErrorFromResponse (E:\CallngBot\Deployment\CallngBot\bot\node_modules\@microsoft\microsoft-graph-client\src\GraphErrorHandler.ts:77:18) at Function.<anonymous> (E:\CallngBot\Deployment\CallngBot\bot\node_modules\@microsoft\microsoft-graph-client\src\GraphErrorHandler.ts:104:31) at step (E:\CallngBot\Deployment\CallngBot\bot\node_modules\tslib\tslib.js:193:27) at Object.next (E:\CallngBot\Deployment\CallngBot\bot\node_modules\tslib\tslib.js:174:57) at E:\CallngBot\Deployment\CallngBot\bot\node_modules\tslib\tslib.js:167:75 at new Promise (<anonymous>) at Object.__awaiter (E:\CallngBot\Deployment\CallngBot\bot\node_modules\tslib\tslib.js:163:16) at Function.GraphErrorHandler.getError (E:\CallngBot\Deployment\CallngBot\bot\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:87:24) at GraphRequest.<anonymous> (E:\CallngBot\Deployment\CallngBot\bot\node_modules\@microsoft\microsoft-graph-client\src\GraphRequest.ts:391:55) { statusCode: 500, code: '9999', requestId: 'dee2344b-6341-439d-bd04-8b2a7dc1e795', date: 2023-07-31T21:39:01.000Z, body: '{"code":"9999","message":"Encountered exception during changing screen sharing role.","innerError":{"date":"2023-08-01T03:09:01","request-id":"dee2344b-6341-439d-bd04-8b2a7dc1e795","client-request-id":"7a5551fc-6fed-3d1e-5ddf-361c327dca5b"}}', headers: Headers { [Symbol(map)]: [Object: null prototype] { 'transfer-encoding': [Array], 'content-type': [Array], 'content-encoding': [Array], vary: [Array], 'strict-transport-security': [Array], 'request-id': [Array], 'client-request-id': [Array], 'x-ms-ags-diagnostic': [Array], date: [Array], connection: [Array] } } }
需求与疑问
- 如何正确创建service-based VoIP通话?若文档存在问题,请给出修改建议
- 如何在应用创建的通话中启用屏幕共享?
- 如何让机器人支持跨租户使用?是否需将tenantId改为
common?(跨租户指Org A开发的应用可被Org B使用) - 文档缺少后续启用共享和摄像头的参数说明,请提供修改后的函数或补充参数
- 更新:调整参数后通话在移动端/桌面端正常,但浏览器端仅闪过后消失,如同未接来电,求解决方案
内容的提问来源于stack exchange,提问作者IAM5K
相关产品推荐
相关产品推荐

