Using an external Phonebook with AnyNode

Route Supervision to receive Data from external Sources

Posted by: Henning // 20th Feb 2021 // Category: //

One big need of most of our customers is a central phonebook, used to identify incoming calls. The CRM holds a bunch of phonenumbers and names and it would be amazing, to use this in MS Teams as phonebook. As of now, that is not possible, but in Version 4.2 of AnyNode a new features was introduced: Route Supervision. This allows us, to get information for a call from an external system using a REST API call from the Anynode.

How does that work?

Once the AnyNode recieves a call, the routing process starts and the ruleset is processed to route the call to the right location. With route superverision, that process was extended by another step:

Process

  1. A Request is sent to an external Service using HTTP(S) JSON
  2. The external service replies with a Response JSON that gives instructions to the AnyNode
  3. The AnyNode proceeds the calls using the information from the response

What kind of information can be processed?

The AnyNode sends all call related information in the Request JSON:

  • sourceAddress
  • destinationAddress
  • assertedAddress
  • firstRedirectAddress
  • lastRedirectAddress
  • transferrerAddress
  • elinAddress

In the Response JSON it expects instructions, how to handle the call:

  • shall the call be contiuned?
    • routeContinue
    • routeIgnore
    • routeReject
  • sourceAddress
  • destinationAddress
  • assertedAddress
  • firstRedirectAddress
  • lastRedirectAddress
  • transferrerAddress
  • elinAddress

In my case, I tell the AnyNode to contiune the Call and set the "sourceAddress Display Name" to the name, from our address book:

{
    "routeContinue": true,
    "sourceAddress": {
        "displayName": "Henning"
    }
}

Configuration on AnyNode

First, make sure you have at least AnyNode 4.2 running.

Than choose the route, that you want to apply this procedure to. In my case, it's my "PSTN to 3CX" Route.

On the first page, enable Route Supervision

Process

Now change to the Supervision Tab and create a new REST Client

Process

Setup the Server Address (in my case a AWS Elastic Beanstalk Instance), also create a HTTP Client and setup your authentication (if you have it, in my Lab I've skipped this.)

Process

Now setup your Request Settings according to your Webservice and check the Accept the rule option, in case the Server does not respond.

Process

UPDATE: Thanks to @mozzeph. I forgot to show the modified Routing forwared profile. The option "Specify whether the changes of dial string should be forwareded" needs do be set to "No" on the RFP of the outgoing node (e.g. MS Teams).

RFP

RFP-Option

That's it! Now everyting is ready.

And on the Server side?

Í use a Laravel based application, to manage the Addressbook. I simply setup an endpoint /addressbook that accepts a GET Request and repsonds with a JSON:

// My HTTP Controller 
public function index(Request $request)
    {
        $bodyContent =  json_decode($request->getContent(), false); // get JSON Body
        $dialstring = $bodyContent->sourceAddress->dialString; // get the dialstring of the caller 
        $dialstring = PhoneNumber::make($dialstring, 'DE')->formatE164(); // Convert to E.164 Format

        $entry = CustomerAddressBookEntry::firstWhere('Phonenumber', $dialstring); // Find in the database 

        if(!$entry){ 
            // IF no entry in the Database, return empty array. 
            $response = [];
            $response['routeContinue'] = true;
        }else{
             //IF Entry in Database was found -> return source name. 
            $response = [];
            $response['routeContinue'] = true;
            $response['sourceAddress']['displayName'] = $entry->Name;
             }

        $json = json_encode($response);

        return response($json, 200)
                  ->header('Content-Type', 'application/json');
    }

This returns the JSON to update the "sourceAddress Display Name" and you see, the Source Name is updated:

Process (There is an error, because the 3CX was not running at this time)

Hope this will help you to set this up yorself :)