forwarding or transfering for scenario?

  • 1
  • Question
  • Updated 3 weeks ago
  • (Edited)
My scenario: I need to forward calls coming in from certain 800#s to other internal numbers (ring groups) using custom routing logic.

What is the best method to use in my case? The Forward or Transfer method?

Additionally, both of those methods are marked under the Light usage plan. These 800#s will be called frequently and it's possible the Light usage plan might not allow enough calls to go through at peak times. What method should I use to route calls for this scenario?
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb

Posted 1 month ago

  • 1
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
BTW, when I try the Forward method I get an error (although the forward does actually take place):

RingCentral.RestException: 'Response:
StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 49
  X-Rate-Limit-Window: 60
  Date: Fri, 19 Apr 2019 19:37:38 GMT
  Server: nginx
  Content-Length: 123
  Content-Type: application/json
}
Content: {
   "errors" : [
      {
         "errorCode" : "TAS-106",
         "message" : "Operation is not allowed"
      }
   ]
}
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,416 Points 5k badge 2x thumb
Hi Tim,

My understanding is that:

Forward = Is used in the case of a call is directly redirected to another number before the call was answered. Think about those forwarding rules.

Transfer:
1. Warm transfer is when a call was picked up and the agent calls another number then connect the call.
2. Blind transfer is when the case a call was picked up by and agent and the agent just transfers the call to another number w/o knowing if that number is available.

Regarding the rate limit, just test your app and graduate it then send a request for increasing the rate limit with your business justification to devsupport@ringcentral.com. Our support engineers will evaluate your case and grant higher rate accordingly.
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
Thanks. What about the error I provided in my second reply? The forward does seem to actually work, but the exception is thrown regardless.
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
Not sure why you got the error while the call was successfully forwarded. The error indicates that some permission was missing but that should not be the case here because you said that it worked.

Can you open your app and add the "Active Call Control" permission back. (I took it off while granting you the "Telephony Session" because basically you will just need the later one.

Try it again and let me know if the error does not go away. Also which number did you forward to? Try several different number to see if any difference.
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
I must have added it back, because Active Call Control was already in there when I just went and checked. I tried it again and got the same exception. I'm trying to forward to an external number (outside of RingCentral) - is that not allowed? Again, it works, the call goes through, but it still throws the error in the code.

If you're not allowed to forward externally, am I able to add a number to my RC test account without cost?
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
It should be ok to forward the call to any number including normal mobile/landline numbers. 

I just test it myself, it works well and I got the correct response  

status: 200,

statusText: 'OK',

What language do you use and do you mind to share a few line of code how you forward the call?

Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
C#. I'm using the test code/project I pulled from your Github site and modified somewhat for testing. I've highlighted the part below that throws the message when a call comes in. I've tried to forward to different numbers but same result.

Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
Hi Tim,

Hold on to the "telephony/sessions" for a while. It looks like we need to add more info to the notification body. Right now it does not have the telephony status and because of that, your code will eventually call the forward function several times as the app receives notification for different stages ringing, forwarding, connected, disconnected etc.

While this may not be the cause of the error you received but it's surely, not the logic you want to build for your app.

For now, I recommend to use the  "/restapi/v1.0/account/~/presence?detailedTelephonyState=true" event instead. With that event filter, you will get the same necessary information such as the telephonySessionId, partyId etc. plus the telephonyStatus, and most probably you want to forward the call to another number after a few "Ringings" or some logic you built behind.

The other issue is that it looks like the forward function in the C# SDK does not return a value. I don't know how you could print out the "callerParty" but it seems never return in my test, event the call is forwarded successfully.

My other test written in Node JS and that was how I got the OK 200 response.

I will check these issues and let you know soon.
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
Thanks for the info. Yes, I do see the function get called multiple times for a single call. Regarding trying to get a return value, I just grabbed test code from another method and didn't change it. I just stopped doing that but that doesn't make a difference with the error.

I'll try the other method you mentioned, but I do have one question: my plan is to do these forwards for only certain numbers that get dialed. I don't want to monitor calls for my entire org, as that would be a huge amount. Can I filter the monitor to only listen for incoming calls from certain 800#s that we have?
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
There are 2 ways to achieve what you want:

1. Use the extension level presence for the extension which has the phone number you want to forward '/restapi/v1.0/account/~/extension/[extensionid]/presence?detailedTelephonyState=true'

2. Use the account level as shown above and check the from number before forwarding the call. You will get the from number from the activeCalls array from the response.

"activeCalls":[{"id":"uMTEw..","direction":"Inbound","from":"+1650513xxxx",

Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
I just tried using the Presence event you mentioned above and I get an exception stating "Not allowed subscribe for events to extensions of other account."

What I did was to create another 10-digit number within the developer console, and then reference that number when setting up the event filter. However, my code is calling Authorize using my main sandbox account.So essentially I'm logged in with one account, and trying to monitor the presence event of another number. Is that not allowed?
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
You cannot monitor other extensions of other account! You can monitor other extensions under the same account if you login with an admin role extension (e.g. 101 or using the main company number)

You wrote: "So essentially I'm logged in with one account, and trying to monitor the presence event of another number. Is that not allowed?" I am not sure about "one account ... another number" Is the number under the same account? If not, No, you can't do that as I explained above.

All in all, only an admin extension can monitor the presence of other extension under the same account!
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
OK - I'm confused then about what account is the admin account. The main account in my sandbox is what I thought was the admin account. I authorize using that number/extension. Here's the snippet:

I also created a second number in my account and that's the number I'm trying to monitor with the presence event, which is when I get that error. What am I doing wrong? Thanks.
(Edited)
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
First of all, you are confused about account and extensions. An account can have multiple extensions (A.K.A users), and by default, it has one extension 101 which has the admin role. You can create more extensions, specify the role and add phone numbers to the extensions.

So your 101 extension must be the admin one and you should be able to subscribe for the presence notification at the account level. I doubt that you specified the extension id incorrectly. The extension Id is the internal id of an extension, NOT the extension number 101, 102 etc.

Here is the code for you to read all extension info under an account and get the extension id for adding to the presence filters.

static private async Task read_extension_info()
        {
            RestClient rc = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, false);
            await rc.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
            if (rc.token.access_token.Length > 0)
            {
                var parameters = new ListExtensionsParameters();
                parameters.type = new [] { "User" };
                var resp = await rc.Restapi().Account().Extension().List(parameters);
                foreach (var record in resp.records)
                {
                    Console.WriteLine("-----");
                    Console.WriteLine("Extension id: " + record.id);
                }
            }
        }   
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
I see. So when I try to monitor the presence event using the extension Id, the presenceStatus = Offline and therefore can't grab other information like session Id. However, if I log into that extension to to force the presence to be online, I can monitor the calls. 

So that leads me to ask, "How do you monitor calls on an extension that isn't tied to an active user account?" Again, I want to monitor an 800 toll-free line and forward calls from there.

Thanks.
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
That seems not true. I just tested to set an extension user's presence status to "offline" then I made a call to the phone number belonged to that extension and I could still get the incoming call notification. Can you try again.

Any phone number must be belonged to an extension, including those toll-free 800 xxx-xxxx. Just check which extension owns the toll-free phone number then set the filter for that extension.
Photo of Tim Falkins

Tim Falkins

  • 240 Points 100 badge 2x thumb
OK - I tried again and monitored it without issues; however, I get this exception when trying to forward the call from that extension (ext 102) when monitoring from my primary account (ext 101):

RingCentral.RestException
  HResult=0x80131500
  Message=Response:
StatusCode: 504, ReasonPhrase: 'Gateway Time-out', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Transfer-Encoding: chunked
  Connection: keep-alive
  X-Rate-Limit-Group: light
  X-Rate-Limit-Limit: 50
  X-Rate-Limit-Remaining: 49
  X-Rate-Limit-Window: 60
  RoutingKey: SJC11P01
  RCRequestId: 635cd774-6a80-11e9-80d5-005056bba23b
  Date: Mon, 29 Apr 2019 13:12:06 GMT
  Server: nginx
  Content-Type: text/plain
}

To reiterate, I'm getting this when trying to call the Forward method using the following code:

                    await rc.Restapi().Account().Telephony().Sessions(sessionId)
                        .Parties(partyId)
                        .Forward().Post(new ForwardTarget
                        {
                            phoneNumber = "+15151234567"
                        });
(Edited)