获取FaxOut RingCentral API的传真状态更改通知

时间:2016-09-30 18:17:45

标签: push-notification status fax ringcentral

我正在使用RingCentral FaxOut API提交传真。该响应中的传真状态为“已排队”。是否有任何订阅来获取该消息的更新传真状态。 RingCentral博客提到了使用GetMessage调用API来获取最新状态。

https://www.ringcentral.com/blog/2015/02/know-fax-transmission-api-succeeded/

他们确实有用户在线推送通知。 https://github.com/ringcentral/ringcentral-js

1 个答案:

答案 0 :(得分:1)

首先,有一个较旧的FaxOut API,然后有较新的RingCentral Platform API消息传真资源。后者是我要在这里解决的问题,如果您使用的是前一版本,请在RingCentral中创建一个支持案例以获得帮助。

不太好的消息是没有直接的方式使用推送通知(订阅)来接收您正在寻找的特定传真状态数据,但是有能力监视消息存储事件,并过滤传入的数据EVENT_DATA.changes.type ==='传真'。

了解如何在订阅中使用message-store eventFilter:https://developers.ringcentral.com/api-docs/latest/index.html#!#RefGetMessageEvent

另外,我在Node.js中创建了一个演示应用程序,向开发人员展示如何创建订阅(它使用您在问题中引用的JavaScript SDK): https://github.com/bdeanindy/ringcentral-subscription-basics(您可以在.env文件中设置配置参数来指定您要使用的eventFilters。

当我从RingCentral发送传真出站时,这是订阅事件流。注意EVENT FILTERS,其中一个是对message-store的订阅,这是使用API​​为开发人员提供传真消息的地方(我在事件的每个阶段都添加了轻量级评论):

Succesfully logged into the RC Account
EVENT FILTERS:  [ '/account/~/extension/2557490012',
  '/account/~/extension/2557490012/presence?detailedTelephonyState=true&aggregated=true',
  '/account/~/extension/2557490012/message-store',
  '/account/~/extension/2557490012/presence/line',
  '/account/~/extension/2557490012/message-store/instant?type=SMS' ]
SUBSCRIPTION CREATED SUCCESSFULLY



Fax Sent
SUBSCRIPTION NOTIFICATION.....
{ uuid: '8004a0b2-7907-458b-8a9b-ec1ba3202f5e',
  event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
  timestamp: '2016-09-30T22:43:53.762Z',
  subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
  body: 
   { extensionId: 2557490012,
     lastUpdated: '2016-09-30T22:43:43.902+0000',
     changes: [ { type: 'Fax', newCount: 1, updatedCount: 0 }, [length]: 1 ] } }


Waiting to connect         
SUBSCRIPTION NOTIFICATION.....
{ uuid: '627d3cdf-1638-4029-9e0b-94bbf3325c61',
  event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
  timestamp: '2016-09-30T22:44:13.776Z',
  subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
  body: 
   { extensionId: 2557490012,
     lastUpdated: '2016-09-30T22:44:01.879+0000',
     changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }
SUBSCRIPTION NOTIFICATION.....
{ uuid: 'f1e1310e-11c7-479d-b988-087379bdcad3',
  event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
  timestamp: '2016-09-30T22:44:23.769Z',
  subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
  body: 
   { extensionId: 2557490012,
     lastUpdated: '2016-09-30T22:44:15.565+0000',
     changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }

Waiting to have sent confirmation
SUBSCRIPTION NOTIFICATION.....
{ uuid: '2148d2d9-8e05-4adc-8019-518774187116',
  event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
  timestamp: '2016-09-30T22:45:33.767Z',
  subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
  body: 
   { extensionId: 2557490012,
     lastUpdated: '2016-09-30T22:45:21.232+0000',
     changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }

但是,您如何确定传真是已发送,排队还是失败?您可以在查询中使用EVENT.event属性进行GET the Message Store list过滤:messageType=Fax&availability=Alive&direction=Outbound&messageStatus=Sent

然后,生成的消息存储记录将在records中有一个新项目,您可以使用to.phoneNumber来匹配发起事件(HTTP POST以发送传真)。

{
      "uri": "{{REMOVED_FOR_SECURITY}}",
      "id": {{REMOVED_FOR_SECURITY}},
      "to": [
        {
          "phoneNumber": "+{{REMOVED_TO_PREVENT_SPAM}}",
          "name": "Hello Fax",
          "messageStatus": "Sent"
        }
      ],
      "type": "Fax",
      "creationTime": "2016-09-30T22:43:43.000Z",
      "readStatus": "Unread",
      "priority": "Normal",
      "attachments": [
        {
          "id": {{REMOVED_FOR_SECURITY}},
          "uri": "{{REMOVED_FOR_SECURITY}}",
          "type": "RenderedDocument",
          "contentType": "application/pdf"
        }
      ],
      "direction": "Outbound",
      "availability": "Alive",
      "messageStatus": "Sent",
      "faxResolution": "High",
      "faxPageCount": 2,
      "lastModifiedTime": "2016-09-30T22:45:21.232Z",
      "coverIndex": 0
    }
相关问题