簡體   English   中英

如何從受監控的來電中檢索 RingCentral 通話錄音?

[英]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屬性。

  1. 通過使用sessionId屬性調用call-log端點來檢索完整的媒體 URL
  2. 使用recordings[0].id屬性手動創建錄制媒體 URL。

注意 1:當通話正在進行時,錄音將不可檢索,即使錄音 ID 存在於呼叫會話通知事件中。 通話結束后不久即可檢索錄音。

注2:通話錄音可以是公司確定的MP3或WAV格式。 為了在檢索錄制媒體文件時區分檢查 MIME 類型的響應Content-Type標頭。

1) 通過通話記錄 API 檢索完整的媒體 URL

call-log API 進行中間 API 調用具有雙重好處,即作為接收媒體 URL 的官方方法和為調用提供更多元數據。 在這種方法中, recording.idcall-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}

在此示例中, sessionId1234567890因此您將擁有如下的 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"
    }
  }
}

2) 手動創建媒體 URL

您可以通過手動構建錄制 URL 來調用錄制 API 端點並直接檢索媒體,如下所示:

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

在此示例中, accountId11111111recordingId44444444 ,如下所示:

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

可以使用~將 URL 路徑中的accountId設置為當前授權用戶的帳戶。 或者,可以通過從event屬性中提取accountId或使用相關party對象中的accountId屬性來顯式設置它。 使用~是設置accountId的推薦方法。

注意:這種方法可能很快,但可能容易出錯,因為 RingCentral 過去曾更改過一次媒體主機名。 雖然沒有預期的未來變化,但調用call-log API 並從響應中檢索完整的媒體 URL 是更安全和推薦的方法。 有關此方法,請參見下文。 這僅包括在內,因為有些人會嘗試此操作並可能在以后遇到問題。

3) 混合方法

調用call-log端點的第一種方法是推薦的方法,但是,它涉及額外的 API 調用,大多數情況下第二種方法應該可以正常工作。

混合方法是按照方法 2 構造 URL,然后如果方法 2 返回 404 或其他錯誤,則回退到方法 1。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM