如何从受监控的来电中检索RingCentral呼叫记录?

问题描述 投票:0回答:1

我通过监听呼叫会话通知(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.13.22.20.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"
    }
  }
}
voice telephony voice-recording ringcentral call-recording
1个回答
0
投票

有两种方法可以使用事件中的信息检索记录,特别是recordings[0].id属性和sessionID属性。

  1. recording属性直接调用recordings[0].id端点。
  2. 间接地通过call-log属性查询sessionId端点

注1:当呼叫正在进行时,即使记录ID出现在呼叫会话通知事件中,也无法进行检索。电话会议结束后不久将立即检索录音​​。

注2:通话记录可以是公司确定的MP3或WAV格式。要区分在检索录制文件时检查MIME类型的响应Content-Type标头。

1)直接通过Recording API

您可以通过手动构建录制URL来直接调用Recording API端点并检索媒体,如下所示:

https://media.ringcentral.com/restapi/v1.0/account/{accountId}/recording/{recordingId}/content

在这个例子中,accountId11111111,而recordingId44444444,用于以下方面:

https://media.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444/content

这种方法可以很快,因为RingCentral在过去曾经更改了一次媒体主机名,因此可能容易出错。虽然没有预期的,未来的变化,调用call-log API并从响应中检索完整的媒体URL是更安全和推荐的方法。请参阅下面的此方法。

2)间接通过Call Log API

call-log API进行中间API调用具有双重好处,即成为接收媒体URL的官方方法,为呼叫提供更多元数据。在这种方法中,recording.id记录中的call-log将与Call Session Notification事件中的recordings[0].id属性匹配。

可以使用事件中的call-log参数调用公司帐户和用户扩展sessionId API,如下所示:

GET /restapi/v1.0/account/~/call-log?sessionId={sessionId}
GET /restapi/v1.0/account/~/extension/~/call-log?sessionId={sessionId}

在这个例子中,sessionId1234567890所以你有一个公司呼叫日志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"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.