Use Amazon Fraud Detector with Amazon Connect for Intelligent routing

Madhan K
4 min readJan 31, 2020

In the previous articles , I wrote about Amazon Connect’s new chat capability which explained about the steps involved in enabling the chat feature that was launched late last year , and also on one other article I wrote on the new Amazon Fraud Detector service which is a fully managed AI service to detect fraudulent activities.

Whilst the Fraud detector service is still in preview and at the time of writing “ONLINE_FRAUD_INSIGHTS” is the only model type that has been enabled , that doesn’t stop us in exploring other potential use cases which might be of interest.

“I tried exploring the possibility of integrating Amazon Fraud Detector with Amazon connect to classify the calls to be either critical (important customers , based on loyalty class etc.,) or fraudulent calls (suspicious callers , tough customers ,spam etc.,) based on the historic call details and route to the relevant agents accordingly”

Interestingly , with minimal effort i could get the service up and running with the Fraud Detector service detecting all the spam calls efficiently( certainly it is subject to the quality of the training data) , and In this article, let’s look at how I went about it, how we can use it, and a sample implementation.

Pre-Requisite

This article assumes that you are already familiar with the concepts of Amazon Connect and have implemented simple voice based contact flows and you also have some knowledge on the Amazon Fraud Detector ( you can refer here for a quick overview and hands-on blog with Amazon Fraud Detector)

Let’s Jump

For this sample implementation , we would create a contact flow with the logic to redirect to a bot if the user legitimate or an experienced agent if the caller has been identified as ‘Notorious’ :)

We will also train the Amazon fraud detector model with some synthetic data for the purpose of this demo application and invoke them in our contact flow to make a real time decision on where to route the call.

Create Amazon Connect — Contact Flow

The above contact flow has been created to test this scenario , it has two lambda invocation , first lambda for a data dip to get the caller information and their profile details , and the latter one that invokes the fraud detector prediction API based on the profile of that user.

for the purpose of this sample implementation , the above mock service was created for data dip where we get the caller’s profile data from the Endpoint address ( Phone Number) , in the real world this will be integrated with the CRM to get the user profile.

Amazon Fraud Detector — Training the Model

Similar to the model that was created in the previous article , Let’s create the model with the following model variables.

PS: For now, the model template requires IP address. And I had a work around by creating an utility function that maps the phone number into an ip addresses in the format of {0–255}.{0–255}.{0.255}.{0.255}. Since the model checks for uniqueness of this field I ended up with this hack for now :)

For the training data , along with the mandatory fields , i have few custom variables added like call_duration ( historic average call time spent by that caller) , customer_class (like a loyalty membership status) & contact_type (voice or chat) etc., this could be customized based on the domain or could be any other data which could help us differentiate legit vs fraudulent callers.

After creating , training and activating the model , Let’s create the detector and also define the outcomes & rules for the detector as follows,

The synthetic data used to train this model has been uploaded in my github repo, once the detector is active , we are now ready to use the prediction API to predict the fraudulent calls in real-time.

Let’s leverage the Fraud detector Prediction API , the following lambda function will be invoked by Amazon connect’s contact flow

The output of this lambda function is the outcome predicted by the model ( pass to agent , approved customer pass to bot etc.,) which will be passed to the check contact attributes to pass to the relevant route.

Conclusion

So , this article covered how cognitive services could complement the Amazon connect and in this case we used the managed fraud detector service to find the fraudulent / high risk callers. And the possibilities of best making use of all these services are endless. In another article , i would focus on integrating all these AI services to have some meaningful insights in context of AWS Cognitive CX.

Complete source code for the this sample application can be found at my git repo here.

--

--