question

Cesar Labrador avatar image
Cesar Labrador asked Phong Vu answered

How to identify to which queue a call belongs after is forwarded from an IVR

Caller's calls are received by an IVR menu first, and based on the selected option, their call gets routed to the corresponding extension. I set a webhook to listen to 'telephony events', so based on which extension is hit, an automated SMS is sent to the caller. Each extension has attached a different template message for each queue.

As I am handling calls for multiple clients, the cases are common but I cannot identify which queue was hit by the caller at the beginning to send the caller the right message, since the text template will change depending on the client (queue) that is trying to be contacted.


rest apicall forwardingsending smsivr
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered

I need to clarify your question.

"Caller's calls are received by an IVR menu first, and based on the selected option, their call gets routed to the corresponding extension."

Do you mean the "corresponding call queue (extension)", right? E.g press 1 => route to "Queue 1"; press 2 => route to "Queue 2" etc.

And,

"Each extension has attached a different template message for each queue"

Do you mean "each call queue" has attached a different template message for SMS auto reply?

And,

"As I am handling calls for multiple clients ..."

Do you mean "multiple users" under the same RingCentral account or "multiple users" under different RingCentral accounts?

You did not mention which telephony session event filter do you use. But here is the trick to identify which call queue is having an incoming call (regardless of via an IVR or a direct call)

Provided that you subscribe for a company (account level) telephony session event notification

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

Then you would get these events after the call is routed to a call queue

{
    "event": "/restapi/v1.0/account/809646xxx/extension/62284877056/telephony/sessions",
    ...
    "body": {
      "sequence": 6,
      "telephonySessionId": "s-a0d17e304ee1ez18a1e628a5fzcdfd0840000",
      ...
      "parties": [
        {
          "accountId": "809646xxx",
          "extensionId": "62284877056",
          "id": "p-a0d17e304ee1ez18a1e628a5fzcdfd0840000-3",
          "direction": "Inbound",
          "to": {
            "phoneNumber": "+1209788xxxx",
            "name": "Paco IVR",
            "extensionId": "62284877056"
          },
          "from": {
            "phoneNumber": "+1650224xxxx",
            "name": "WIRELESS CALLER"
          },
          "status": {
            "code": "Setup",
            "rcc": false
          },
          ...
        }
      ],
      "origin": {
        "type": "Call"
      }
    }
}
  
{
    "event": "/restapi/v1.0/account/809646xxx/extension/62284877056/telephony/sessions",
    ...
    "body": {
      "sequence": 7,
      "telephonySessionId": "s-a0d17e304ee1ez18a1e628a5fzcdfd0840000",
      ...
      "parties": [
        {
          "accountId": "809646xxx",
          "extensionId": "62284877056",
          "id": "p-a0d17e304ee1ez18a1e628a5fzcdfd0840000-3",
          "direction": "Inbound",
          "to": {
            "phoneNumber": "+1209788XXXX",
            "name": "Paco IVR",
            "extensionId": "62284877056"
          },
          "from": {
            "phoneNumber": "+1650224XXX",
            "name": "Demo Queue - WIRELESS CALLER"
          },
          "status": {
            "code": "Proceeding",
            "rcc": false
          },
          ...
        }
      ],
      "origin": {
        "type": "Call"
      }
    }
}

The extension id in the parties array is the extension id of the call queue that receiving the incoming call. The from.phoneNumber is the number of the caller. So, map the call queue extension id to the message template and you can get the right template for each call queue and reply to the from.phoneNumber.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys