【问题标题】:Get Notification on Fax Status Change for FaxOut RingCentral API获取有关 FaxOut RingCentral API 的传真状态更改的通知
【发布时间】:2016-09-30 18:17:45
【问题描述】:

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

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

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

【问题讨论】:

    标签: push-notification status fax ringcentral


    【解决方案1】:

    首先是较旧的 FaxOut API,然后是较新的 RingCentral Platform API Message-Fax 资源。后者是我要在这里解决的问题,如果您使用的是前一个版本,请向 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 文件中设置配置参数来指定您要使用的事件过滤器)。

    这是我从 RingCentral 向外发送传真时的订阅事件流。注意事件过滤器,其中之一是订阅message-store,这是使用 API 为开发人员提供传真消息的地方(我在事件的每个阶段上方添加了 light cmets):

    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
        }
    

    【讨论】:

    • 感谢您的帮助。我将尝试这种方法,并将在此处发布更新。
    • 酷。期待看看这是否有助于解决您的用例。
    • 我能够使用您的 nodejs 订阅项目,并且我看到在以 updatedCount 形式发送传真时收到通知。仍在努力获取有关该消息事件的更多信息并匹配传出传真以获得最终状态。
    • 如果您需要任何其他帮助,请告诉我。
    • 我终于采用了在发送传真时存储传真 URI 的路线,然后使用 RabbitMQ 的延迟队列获取传真状态。
    猜你喜欢
    • 1970-01-01
    • 2012-06-21
    • 2021-04-20
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多