[英]How can I retrieve a RingCentral call recording from a monitored incoming call?
我正在通过侦听呼叫会话通知 (CSN) telephony/sessions
事件过滤器来监视 RingCentral 上的来电:
/restapi/v1.0/account/~/extension/~/telephony/sessions
由此,我将收到如下事件。 recordings
属性将出现以指示录音可用。 我怎样才能找回这个录音?
{
"uuid":"12345678901234567890",
"event":"/restapi/v1.0/account/11111111/extension/22222222/telephony/sessions",
"timestamp":"2019-03-08T22:30:40.059Z",
"subscriptionId":"11112222-3333-4444-5555-666677778888",
"ownerId":"33333333",
"body":{
"sequence":7,
"sessionId":"1234567890",
"telephonySessionId":"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"serverId":"10.11.12.13.TAM",
"eventTime":"2019-03-08T22:30:39.938Z",
"parties":[
{
"accountId":"11111111",
"extensionId":"22222222",
"id":"cs12345678901234567890-2",
"direction":"Inbound",
"to":{
"phoneNumber":"+16505550100",
"name":"Jane Doe",
"extensionId":"22222222"
},
"from":{
"phoneNumber":"+14155550100",
"name":"John Smith"
},
"recordings":[
{
"id":"44444444",
"active":false
}
],
"status":{
"code":"Answered",
"rcc":false
},
"missedCall":false,
"standAlone":false,
"muted":false
}
],
"origin":{
"type":"Call"
}
}
}
有两种使用呼叫会话通知 (CSN) 事件中的信息检索录音的方法,特别是recordings[0].id
属性和sessionID
属性。
sessionId
属性调用call-log
端点来检索完整的媒体 URLrecordings[0].id
属性手动创建录制媒体 URL。注意 1:当通话正在进行时,录音将不可检索,即使录音 ID 存在于呼叫会话通知事件中。 通话结束后不久即可检索录音。
注2:通话录音可以是公司确定的MP3或WAV格式。 为了在检索录制媒体文件时区分检查 MIME 类型的响应
Content-Type
标头。
对call-log
API 进行中间 API 调用具有双重好处,即作为接收媒体 URL 的官方方法和为调用提供更多元数据。 在这种方法中, recording.id
在call-log
记录将匹配recordings[0].id
在呼叫会话通知事件属性。
可以使用事件中的sessionId
参数call-log
公司帐户和用户扩展call-log
API,如下所示:
GET /restapi/v1.0/account/~/call-log?sessionId={sessionId}
GET /restapi/v1.0/account/~/extension/~/call-log?sessionId={sessionId}
在此示例中, sessionId
为1234567890
因此您将拥有如下的 Company Call Log API URL
GET /restapi/v1.0/account/~/call-log?sessionId=1234567890
响应对象将有一个recording
属性,提供超媒体链接以获取媒体文件。 该文件可以是 WAV 或 MP3 格式,在响应Content-Type
标头中进行通信。
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log/1234567890ABCDEFGabcdefgh?view=Simple",
"id": "1234567890ABCDEFGabcdefgh",
"sessionId": "1234567890",
"startTime": "2019-03-08T22:30:29.505Z",
"duration": 35,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"to": {
"phoneNumber": "+16505550100",
"name": "Jane Doe"
},
"from": {
"phoneNumber": "+14155550100",
"name": "John Smith",
"location": "San Francisco, CA"
},
"recording": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444",
"id": "44444444",
"type": "OnDemand",
"contentUri": "https://media.ringcentral.com/restapi/v1.0/account/111111111/recording/44444444/content"
},
"extension": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/111111111/extension/22222222",
"id": 22222222
},
"reason": "Accepted",
"reasonDescription": "The call connected to and was accepted by this number."
}
],
"paging": {
"page": 1,
"perPage": 100,
"pageStart": 0,
"pageEnd": 0
},
"navigation": {
"firstPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
},
"lastPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
}
}
}
您可以通过手动构建录制 URL 来调用录制 API 端点并直接检索媒体,如下所示:
https://media.ringcentral.com/restapi/v1.0/account/{accountId}/recording/{recordingId}/content
在此示例中, accountId
为11111111
, recordingId
为44444444
,如下所示:
https://media.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444/content
可以使用~
将 URL 路径中的accountId
设置为当前授权用户的帐户。 或者,可以通过从event
属性中提取accountId
或使用相关party
对象中的accountId
属性来显式设置它。 使用~
是设置accountId
的推荐方法。
注意:这种方法可能很快,但可能容易出错,因为 RingCentral 过去曾更改过一次媒体主机名。 虽然没有预期的未来变化,但调用
call-log
API 并从响应中检索完整的媒体 URL 是更安全和推荐的方法。 有关此方法,请参见下文。 这仅包括在内,因为有些人会尝试此操作并可能在以后遇到问题。
调用call-log
端点的第一种方法是推荐的方法,但是,它涉及额外的 API 调用,大多数情况下第二种方法应该可以正常工作。
混合方法是按照方法 2 构造 URL,然后如果方法 2 返回 404 或其他错误,则回退到方法 1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.