简体   繁体   English

如何从受监控的来电中检索 RingCentral 通话录音?

[英]How can I retrieve a RingCentral call recording from a monitored incoming call?

I'm monitoring incoming calls on RingCentral by listening for the Call Session Notifications (CSN) telephony/sessions event filter:我正在通过侦听呼叫会话通知 (CSN) telephony/sessions事件过滤器来监视 RingCentral 上的来电:

/restapi/v1.0/account/~/extension/~/telephony/sessions

From this, I will receive events like the following.由此,我将收到如下事件。 The recordings property will appear to indicate a recording is available. recordings属性将出现以指示录音可用。 How can I retrieve this recording?我怎样才能找回这个录音?

{
  "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"
    }
  }
}

There are two ways to retrieve the recording using information in the Call Session Notification (CSN) event, specifically the recordings[0].id property and the sessionID property.有两种使用呼叫会话通知 (CSN) 事件中的信息检索录音的方法,特别是recordings[0].id属性和sessionID属性。

  1. retrieving a full media URL by calling the call-log endpoint with the sessionId property通过使用sessionId属性调用call-log端点来检索完整的媒体 URL
  2. manually creating recording media URL using the recordings[0].id property.使用recordings[0].id属性手动创建录制媒体 URL。

Note 1: While the call is ongoing, the recording will not be available for retrieval, even when the recording id is present in the Call Session Notification event.注意 1:当通话正在进行时,录音将不可检索,即使录音 ID 存在于呼叫会话通知事件中。 The recording will be available to be retrieved shortly after the call concludes.通话结束后不久即可检索录音。

Note 2: Call recordings can be in MP3 or WAV format determined by the company.注2:通话录音可以是公司确定的MP3或WAV格式。 To distinguish check the response Content-Type header for the MIME type when retrieving the recording media file.为了在检索录制媒体文件时区分检查 MIME 类型的响应Content-Type标头。

1) Retrieving Full Medial URL via Call Log API 1) 通过通话记录 API 检索完整的媒体 URL

Making an intermediate API call to the call-log API has the dual benefits of being the official approach for receiving a media URL an providing more metadata for the call.call-log API 进行中间 API 调用具有双重好处,即作为接收媒体 URL 的官方方法和为调用提供更多元数据。 In this approach, the recording.id in the call-log record will match the recordings[0].id property in the Call Session Notification event.在这种方法中, recording.idcall-log记录将匹配recordings[0].id在呼叫会话通知事件属性。

Both the company account and user extension call-log APIs can be called with the sessionId parameter from the event as shown:可以使用事件中的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}

In this example, the sessionId is 1234567890 so you would have a Company Call Log API URL as follows在此示例中, sessionId1234567890因此您将拥有如下的 Company Call Log API URL

GET /restapi/v1.0/account/~/call-log?sessionId=1234567890

The response object will have a recording property that provides hypermedia links to get the media file.响应对象将有一个recording属性,提供超媒体链接以获取媒体文件。 The file can be WAV or MP3 format which is communicated in the response Content-Type header.该文件可以是 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"
    }
  }
}

2) Manually Creating Media URL 2) 手动创建媒体 URL

You can call the Recording API endpoint and retrieve the media directly by manually constructing the recording URL as follows:您可以通过手动构建录制 URL 来调用录制 API 端点并直接检索媒体,如下所示:

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

In this example, the accountId is 11111111 and the recordingId is 44444444 for the following:在此示例中, accountId11111111recordingId44444444 ,如下所示:

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

The accountId in the URL path can be set to the currently authorized user's account using ~ .可以使用~将 URL 路径中的accountId设置为当前授权用户的帐户。 Alternately, it can be set explicitly by extracting the accountId from the event property or using the accountId property in the relevant party object.或者,可以通过从event属性中提取accountId或使用相关party对象中的accountId属性来显式设置它。 Using ~ is the recommended way to set accountId .使用~是设置accountId的推荐方法。

Note: This this approach can be quick, it may be error prone as RingCentral has changed the media hostname once in the past.注意:这种方法可能很快,但可能容易出错,因为 RingCentral 过去曾更改过一次媒体主机名。 While there are no anticipated, future changes, calling the call-log API and retrieving the full media URL from the response is the safer and recommended approach.虽然没有预期的未来变化,但调用call-log API 并从响应中检索完整的媒体 URL 是更安全和推荐的方法。 See below for this approach.有关此方法,请参见下文。 This is only included as some people will try this and potentially run into issues later.这仅包括在内,因为有些人会尝试此操作并可能在以后遇到问题。

3) Hybrid Approach 3) 混合方法

The first approach of calling the call-log end point is the recommended approach, however, it involves an extra API call and most of the time the second approach should work fine.调用call-log端点的第一种方法是推荐的方法,但是,它涉及额外的 API 调用,大多数情况下第二种方法应该可以正常工作。

A hybrid approach is to construct the URL as in approach 2 and then fall back to approach 1 if approach 2 returns a 404 or other error.混合方法是按照方法 2 构造 URL,然后如果方法 2 返回 404 或其他错误,则回退到方法 1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM