BookmarkSubscribeRSS Feed

Hackathon Highlights: Banks applying AI to transform customer complaints into business success

Started ‎03-02-2020 by
Modified ‎07-28-2020 by
Views 3,499

When choosing our AI Hackathon project, Bartosz 🇵🇱@kamilia 🇫🇷@milad 🇩🇪, and I thought of how banks are under unprecedented pressure to deliver more personalized customer experiences. While their survival depends on it, a survey by international consulting firm Boston Consulting Group (BCG) found that 86% of banking executives are overwhelmed by its complexity.



SASHackathonHighlights.jpgSo, inspired by the Royal Bank of Scotland's success in this realm, we decided to model our project according to BCG recommendations to focus on four priorities: (1) Reinvent the consumer journey, (2) Leverage the power of data, (3) Redefine the operating model, and (4) Build a digital driven organization. In one day, we created and deployed an AI web application using SAS Visual and Text Analytics capabilities: Sentiment Analysis, Topic Discovery, and Compelling Data Visualization tools to help banks turn customer complaints into business success.


Reinvent the consumer journey


Anyone would agree that one area financial institutions can always improve on, is how they handle customer complaints. So our goal with the proposed solution is to make the consumer journey as painless as possible.


We wanted to change this customer experience…

before.jpgFor this one...




José does not have to navigate a page with multiple links to get to the form. He lands on the form directly. All he needs to do is type in his complaint and hit the send button. Instantly, his message is detected as negative and is offered immediate resolution. If he elects to be contacted, a bank associate would reach out to him within minutes.


Using Sentiment Analysis, emotions expressed in a customer’s message can be computationally identified and categorized as positive, neutral, or negative. Banks do not have to create multiple forms confusing customers. With one simple form, AI can interact with the customer and automatically route the message on the back-end.


Sounds complex to implement, not really! This is how we deployed Sentiment Analysis using Flask, a micro web framework written in Python, and SAS Visual Text Analytics (VTA):


from flask import Flask,redirect, render_template, request
app = Flask(__name__)

if __name__ == "__main__":
  #1- Import the Python client to SAS Cloud Analytic Services (CAS)
  import swat

  #2- Start a CAS Session
  cas_session = swat.CAS(hostname='localhost', port=5570, username='user',password='pass')

  #3- Load action set for Sentiment Analysis
  # Run the Flask application"",port=5000)
def main():
  return render_template('nlp.html',domain='')
def analyze():
  # Read the text sent by customer
  _text = request.form['text']

  #4- Load the text in a CAS table
  cas_session.datastep.runcode('''data casuser.user_comments; Id=1 Comm='%s'; run; '''% _text)
  #5- Run Sentiment Analysis on the CAS table
  cas_session.sentimentAnalysis.applySent(casOut={"name":"user_comments_sent", "replace":True},
                                       docId="Id", text="Comm", table={"name":"user_comments"})
  #6- Read score from CAS table
  result = cas_session.CASTable('user_comments_sent').get_value(0,'_score_')

  # Interact with customer based on score
  if result < 0.5:
    return '<p>Sorry about the inconvenience. Would you like to be contacted immediately?</p>'
    return '<p>For your Loyality we would like to offer you a discount!</p>'
  # Drop the CAS table 


Essentially, it took 6 lines of code to connect to CAS and score a customer’s comment. Out-of-the-box, VTA can score text in 13 different languages with the default Sentiment Analysis Model making it easier to deploy the technology. If the default model does not meet your business needs, you can train and use your own. The list of supported languages and details about Sentiment Scoring can be found here.


Automatically detecting a customer in need of immediate help is great. But that raises an important question: how can banks keep up with large volumes of such requests and offer timely resolution? We believe applying AI again for Topic Discovery can help with that.


While Sentiment Analysis did not require any data to pre-train models, Topic Discovery does; which leads us to the next priority.


Leverage the power of data


In José’s example, even though his complaint was short, the pre-trained Topic Discovery model we deployed was able to accurately detect a product, sub-product, and issue category. His complaint would have been automatically routed to the team responsible for account closing and assigned to an associate who handles checking and savings accounts.




To train the model, we processed in VTA over 200k recent and publicly available complaints from the Consumer Financial Protection Bureau. The resulting product we deployed is known as an Analytic Store, or ASTORE, a transportable file capable of scoring new data in a variety of environments.


Below, a sample Python code, illustrating how to load and score new data with a pre-trained ASTORE:


#1- Import swat and os
import swat
import os

#2- Start a CAS Session
cas_session = swat.CAS(hostname='localhost', port=5570, username='user',password='pass')

#3- Load action set for astore

#4- Load ASTORE file to CAS

with open(fileName, mode='rb') as file: 
      fileContent =

cas_session.astore.upload(rstore='complaint_categories_model', store = swat.blob(fileContent))

#5- Load complaint to CAS Table 
comp = "You can not get it right, I am tired of this, closing all my accounts"

cas_session.datastep.runcode('''data casuser.user_comments; Id=1 Comm='%s'; run; '''% comp)

#6- Score complaint  
cas_session.astore.score(rstore='complaint_categories_model', table='user_comments', 
                         multiplecasout= [dict(name='scored_table_1', replace=True),
                                          dict(name='scored_table_2', replace=True),
                                          dict(name='scored_table_3', replace=True)])

#7- Read the categories  
res = cas_session.CASTable('scored_table_3', caslib='casuser').to_dict()['_category_']


In addition to sentiment, automatically detecting categories will help prioritize and efficiently route complaints. It could enable banks to offer personalized resolutions in a timely manner and, thus, enhance customer experience.


As the AI model matures, it is not a stretch to say, many issues could be resolved without any human intervention. However, when redefining its operating model, it is essential for a bank to recognize when customers actually want a human experience.


Redefine the operating model


BCG noted:

Consumers increasingly want the best of both worlds: a digital experience when they need speed and convenience and a human experience when they need advice for more complex products such as investments or mortgages or when they have an issue or problem.


When it comes to providing a better human experience for a consumer having an issue, we were inspired by Royal Bank of Scotland’s success story. To empower its associates to make fast data-driven decisions, the bank used SAS Visual Analytics to quickly put insights within everyone's reach.


That is what we envisioned in our solution. When an associate is evaluating a complaint, he is also presented with a holistic view of the customer’s experience. In José’s case illustrated above, the associate can see he has been with the bank for 2 years and previously reached out to close his credit card account. Equipped with these insights, the associate can better engage José when calling to resolve the complaint.


Furthermore, data visualization tools could be used to provide data-driven training for employees and measure the effectiveness of new operating models. Here is an example of an interactive dashboard we built to help track complaint trends and measure how well new models are doing:




Using similar dashboards, the Royal Bank of Scotland was able to measure the effectiveness of their data-driven initiatives. They reported a 25% decrease in overall complaints due to faster resolution, and for one particular team, numbers went down from 20 to 1 complaint per month.


Nonetheless, because banks have been discouraged by disappointing initial results, slow implementation, and inability to scale across the organization, many are still on the fence to prioritize AI initiatives. Fortunately for banks, the AI solutions we showcased are integrated within a platform that adheres to the decisioning framework shown below. 




The platform addresses challenges across the entire analytical lifecycle and embeds into business decision processes, thus, lowering the risk for banks to build digital driven organizations.  


Build a digital driven organization


I invite you to take the first steps to build a digital driven organization by trying for free SAS Visual Analytics and other solutions of the Viya platform here.


To learn more about SAS Visual Text Analytics you can request a demo here or check out available training options here.


I hope you will enjoy it as much as we did and feel free to contact us with your questions and comments.



Version history
Last update:
‎07-28-2020 02:16 PM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags