如何使用API创建一个新的xAssist调用
1.收集有效的登录凭证。
2.使用/rtc/createCall
端点设置一个后置调用,并按照下面的解释设置请求主体。
注释的请求体JSON:
{
"callTitle": "Test Call", \\Name of the call
"callReason": "STANDARD", \\Either Standard or SERVICE_REQUEST
"callType": "SFU", \\ Defines the call technology used eg. MESH for 1:1 calls or SFU for Multicalls
"invitedContacts": [ \\ List of multiple CallLogContact objects
{
"displayName": "Tester",
"domain": "ubimax",
"email": "test@test.de",
"phoneNumber": "",
"userDbId": 8, \\The database id of the user, which the contact is linked too.
"userId": "tester" \\The user id id of the user, which the contact is linked too.
}
],
"invitedTeams": [], \\ Leave empty or add a team object to invite a whole team.
"joinAnonymousAllowed": true, \\ Set to true to allow anonymous joins else false
"informOthersDirectly": true, \\ Set to true to trigger the call notification pop-up on invited contacts screen
"creatorUser": 12, \\ The database id of the user. Leave empty or Set it to create calls on behalf of someone, behaving as a broker.
注释的响应体JSON(CallLog
对象):
{
"id": 842, \\Incremental id generated by the database
"callId": "e76e1d8a-8267-4bd4-ba5c-00ab76743e74", \\UUID generated by the application
"anonymousJoinAllow": true, \\Whether anonymous joins are allowed or not
"callStatus": "Ended", \\Possible values: Planned, Started or Ended
"creatorContact": { \\ CallLogContact object. References the user that generated the call or the “creatorUser” specified when creating the call.
...
}
"invitedContacts": [ \\ List of multiple CallLogContact objects
{
...
}
]
"callEvents": [ \\ List of multiple call Events
{
"id": 234, \\Incremental id generated by the database
"type": "Created", \\Possible values: Created, Join, Leave, between others.
"contact": { \\ CallLogContact object. References the user related with the current event.
...
}
}
]
3.服务器通过WebSocket、邮件或短信(如果在CallLogContactObject
中设置)通知被邀请的联系人。
如何知道使用API的调用状态
1.收集有效的登录凭证。
2.使用/rtc/getCallLogById?callId=value
端点设置一个获取调用,并使用从上述createCall
端点的响应中获得的callId
。
注释的响应体JSON:
与createCall
端点的响应相同。例如,对于一个由callertest1向callertest2发起的正在进行的网状呼叫,事件将如下:
"callEvents": [
{
"id": 697,
"type": "Created",
"contact": {
"id": 1,
"userId": "callertest1",
"userDbId": 8
}
},
{
"id": 698,
"type": "Join",
"contact": {
"id": 1,
"userId": "callertest1",
"userDbId": 8
}
},
{
"id": 699,
"type": "Join",
"contact": {
"id": 2,
"userId": "callertest2",
"userDbId": 9
},
}
],
如何从连接器创建一个网状呼叫
使用RtcControllerApi
所暴露的方法。其中最突出的是createCallForContacts
来创建呼叫,getCallLogById
来了解呼叫的状态。
要创建一个呼叫,使用之前提到的creatorUser
属性。将其设置为智能眼镜用户的userDbId
,并将专家用户和连接器用户添加到invitedContacts
数组中。因此,连接器最终表现得像一个经纪人。请记住,只有在专家用户接听电话后,智能眼镜用户才会被调用。
序列图
Node.js例子
Node.js示例调用(已剥离,可能需要进一步的安全头文件和cookies,通过Login收集)。
fetch("https://<serverurl>/rtc/createCall", {
"headers": {
"authorization": "Bearer <token>",
},
"body": "{\"callType\":\"SFU\",\"invitedContacts\":[{\"userId\":\"tester\",\"userDbId\":8,\"email\":\"test@test.com\",\"domain\":\"ubimax\",\"displayName\":\"Tester\",\"phoneNumber\":null}],\"invitedTeams\":[],\"joinAnonymousAllowed\":false,\"callTitle\":\"New Call\",\"plannedDateTime\":null,\"callReason\":\"STANDARD\"}",
"method": "POST",
"mode": "cors"
});