Build an Amazon Bedrock based digital lending solution on AWS
In this post, we propose a solution using DigitalDhan, a generative AI-based solution to automate customer onboarding and digital lending. The proposed solution uses Amazon Bedrock Agents to automate services related to KYC verification, credit and risk assessment, and notification. Financial institutions can use this solution to help automate the customer onboarding, KYC verification, credit decisioning, credit underwriting, and notification processes.
Digital lending is a critical business enabler for banks and financial institutions. Customers apply for a loan online after completing the know your customer (KYC) process. A typical digital lending process involves various activities, such as user onboarding (including steps to verify the user through KYC), credit verification, risk verification, credit underwriting, and loan sanctioning. Currently, some of these activities are done manually, leading to delays in loan sanctioning and impacting the customer experience.
In India, the KYC verification usually involves identity verification through identification documents for Indian citizens, such as a PAN card or Aadhar card, address verification, and income verification. Credit checks in India are normally done using the PAN number of a customer. The ideal way to address these challenges is to automate them to the extent possible.
The digital lending solution primarily needs orchestration of a sequence of steps and other features such as natural language understanding, image analysis, real-time credit checks, and notifications. You can seamlessly build automation around these features using Amazon Bedrock Agents. Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies such as AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities to build generative AI applications with security, privacy, and responsible AI. With Amazon Bedrock Agents, you can orchestrate multi-step processes and integrate with enterprise data using natural language instructions.
In this post, we propose a solution using DigitalDhan, a generative AI-based solution to automate customer onboarding and digital lending. The proposed solution uses Amazon Bedrock Agents to automate services related to KYC verification, credit and risk assessment, and notification. Financial institutions can use this solution to help automate the customer onboarding, KYC verification, credit decisioning, credit underwriting, and notification processes. This post demonstrates how you can gain a competitive advantage using Amazon Bedrock Agents based automation of a complex business process.
Why generative AI is best suited for assistants that support customer journeys
Traditional AI assistants that use rules-based navigation or natural language processing (NLP) based guidance fall short when handling the nuances of complex human conversations. For instance, in a real-world customer conversation, the customer might provide inadequate information (for example, missing documents), ask random or unrelated questions that aren’t part of the predefined flow (for example, asking for loan pre-payment options while verifying the identity documents), natural language inputs (such as using various currency modes, such as representing twenty thousand as “20K” or “20000” or “20,000”). Additionally, rules-based assistants don’t provide additional reasoning and explanations (such as why a loan was denied). Some of the rigid and linear flow-related rules either force customers to start the process over again or the conversation requires human assistance.
Generative AI assistants excel at handling these challenges. With well-crafted instructions and prompts, a generative AI-based assistant can ask for missing details, converse in human-like language, and handle errors gracefully while explaining the reasoning for their actions when required. You can add guardrails to make sure that these assistants don’t deviate from the main topic and provide flexible navigation options that account for real-world complexities. Context-aware assistants also enhance customer engagement by flexibly responding to the various off-the-flow customer queries.
Solution overview
DigitalDhan, the proposed digital lending solution, is powered by Amazon Bedrock Agents. They have developed a solution that fully automates the customer onboarding, KYC verification, and credit underwriting process. The DigitalDhan service provides the following features:
- Customers can understand the step-by-step loan process and the documents required through the solution
- Customers can upload KYC documents such as PAN and Aadhar, which DigitalDhan verifies through automated workflows
- DigitalDhan fully automates the credit underwriting and loan application process
- DigitalDhan notifies the customer about the loan application through email
We have modeled the digital lending process close to a real-world scenario. The high-level steps of the DigitalDhan solution are shown in the following figure.
The key business process steps are:
- The loan applicant initiates the loan application flow by accessing the DigitalDhan solution.
- The loan applicant begins the loan application journey. Sample prompts for the loan application include:
- “What is the process to apply for loan?”
- “I would like to apply for loan.”
- “My name is Adarsh Kumar. PAN is ABCD1234 and email is [email protected]. I need a loan for 150000.”
- The applicant uploads their PAN card.
- The applicant uploads their Aadhar card.
- The DigitalDhan processes each of the natural language prompts. As part of the document verification process, the solution extracts the key details from the uploaded PAN and Aadhar cards such as name, address, date of birth, and so on. The solution then identifies whether the user is an existing customer using the PAN.
- If the user is an existing customer, the solution gets the internal risk score for the customer.
- If the user is a new customer, the solution gets the credit score based on the PAN details.
- The solution uses the internal risk score for an existing customer to check for credit worthiness.
- The solution uses the external credit score for a new customer to check for credit worthiness.
- The credit underwriting process involves credit decisioning based on the credit score and risk score, and calculates the final loan amount for the approved customer.
- The loan application details along with the decision are sent to the customer through email.
Technical solution architecture
The solution primarily uses Amazon Bedrock Agents (to orchestrate the multi-step process), Amazon Textract (to extract data from the PAN and Aadhar cards), and Amazon Comprehend (to identify the entities from the PAN and Aadhar card). The solution architecture is shown in the following figure.
The key solution components of the DigitalDhan solution architecture are:
- A user begins the onboarding process with the DigitalDhan application. They provide various documents (including PAN and Aadhar) and a loan amount as part of the KYC
- After the documents are uploaded, they’re automatically processed using various artificial intelligence and machine learning (AI/ML) services.
- Amazon Textract is used to extract text information from the uploaded documents.
- Amazon Comprehend is used to identify entities such as PAN and Aadhar.
- The credit underwriting flow is powered by Amazon Bedrock Agents.
- The knowledge base contains loan-related documents to respond to loan-related queries.
- The loan handler AWS Lambda function uses the information in the KYC documents to check the credit score and internal risk score. After the credit checks are complete, the function calculates the loan eligibility and processes the loan application.
- The notification Lambda function emails information about the loan application to the customer.
- The Lambda function can be integrated with external credit APIs.
- Amazon Simple Email Service (Amazon SES) is used to notify customers of the status of their loan application.
- The events are logged using Amazon CloudWatch.
Amazon Bedrock Agents deep dive
Because we used Amazon Bedrock Agents heavily in the DigitalDhan solution, let’s look at the overall functioning of Amazon Bedrock Agents. The flow of the various components of Amazon Bedrock Agents is shown in the following figure.
The Amazon Bedrock agents break each task into subtasks, determine the right sequence, and perform actions and knowledge searches. The detailed steps are:
- Processing the loan application is the primary task performed by the Amazon Bedrock agents in the DigitalDhan solution.
- The Amazon Bedrock agents use the user prompts, conversation history, knowledge base, instructions, and action groups to orchestrate the sequence of steps related to loan processing. The Amazon Bedrock agent takes natural language prompts as inputs. The following are the instructions given to the agent:
- We configured the agent preprocessing and orchestration instructions to validate and perform the steps in a predefined sequence. The few-shot examples specified during the agent instructions boost the accuracy of the agent performance. Based on the instructions and the API descriptions, the Amazon Bedrock agent creates a logical sequence of steps to complete an action. In the DigitalDhan example, instructions are specified such that the Amazon Bedrock agent creates the following sequence:
- Greet the customer.
- Collect the customer’s name, email, PAN, and loan amount.
- Ask for the PAN card and Aadhar card to read and verify the PAN and Aadhar number.
- Categorize the customer as an existing or new customer based on the verified PAN.
- For an existing customer, calculate the customer internal risk score.
- For a new customer, get the external credit score.
- Use the internal risk score (for existing customers) or credit score (for external customers) for credit underwriting. If the internal risk score is less than 300 or if the credit score is more than 700, sanction the loan amount.
- Email the credit decision to the customer’s email address.
- Action groups define the APIs for performing actions such as creating the loan, checking the user, fetching the risk score, and so on. We described each of the APIs in the OpenAPI schema, which the agent uses to select the most appropriate API to perform the action. Lambda is associated with the action group. The following code is an example of the
create_loan
API. The Amazon Bedrock agent uses the description for thecreate_loan
API while performing the action. The API schema also specifiescustomerName
,address
,loanAmt
,PAN
, andriskScore
as required elements for the APIs. Therefore, the corresponding APIs read the PAN number for the customer (verify_pan_card
API), calculate the risk score for the customer (fetch_risk_score
API), and identify the customer’s name and address (verify_aadhar_card
API) before calling thecreate_loan
API.