Integrating n8n: Building a Bank Loan Assistant
Overview
The Bank Loan Assistant is an intelligent service system designed to streamline the consultation, application, and management processes for business loans. By combining OneAI's intelligent Q&A capabilities with n8n's workflow automation features, it provides users with a comprehensive loan service experience.
Business Value
Technical Highlights
System Architecture
Core Workflow
Loan Application Workflow
Interaction Sequence
Interaction Examples
User consults the assistant about business loan-related questions
User applies for a business loan, guided to provide necessary information
Officially submit the loan application and obtain the application number
I want to apply for a business loan.
Company Name: Example Technology Co., Ltd
Contact Person: John Doe
Loan Amount: 200,000
Loan Term: 1 year
Purpose: For expanding production scale and purchasing new equipment
Meets the criteria, bank manager receives an email for loan approval
Query approval progress (under review)
Query approval progress (approved)
User's loan application amount is too large (exceeds the maximum loan amount in the business loan policy), automatically rejected and informed of the reason
I want to apply for a business loan.
Company Name: Example Technology Co., Ltd
Contact Person: John Doe
Loan Amount: 200,000,000,000
Loan Term: 1 year
Purpose: For expanding production scale and purchasing new equipment
User's loan application purpose is non-compliant (real estate investment), automatically rejected and informed of the reason
I want to apply for a business loan.
Company Name: Example Technology Co., Ltd
Contact Person: John Doe
Loan Amount: 200,000
Loan Term: 1 year
Purpose: Real estate investment
Preparation
To fully run this example, please complete the following preparations before starting to build:
- OneAPI requirements
- Deploy n8n
- Deploy PostgreSQL database
- n8n Credentials configuration
OneAI Version
- It is recommended to upgrade to version 3.2_u4 or above, and also upgrade the frontend to the corresponding latest version.
Deploy n8n
Please refer to the documentation: n8n Integration
- Refer to 'Deploy n8n' to complete the deployment of n8n.
- Refer to 'n8n Calls OneAI API' to complete the installation of the OneAI community node.
Deploy PostgreSQL Database
If you have already created a PostgreSQL database when deploying n8n, you can use that database directly without additional deployment.
Please deploy a PostgreSQL database instance in the network environment where n8n is located. After deployment, please carefully record the following information:
- Database connection address
- Database username
- Database password
Next, execute the following SQL script in PostgreSQL to create the loan application table:
CREATE TABLE loan_applications (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
company_name VARCHAR(255) NOT NULL,
contact_person VARCHAR(100) NOT NULL,
loan_amount DECIMAL(15, 2) NOT NULL,
loan_term VARCHAR(50) NOT NULL,
purpose TEXT,
application_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
status VARCHAR(50) NOT NULL DEFAULT 'Pending Review',
review_notes TEXT,
assigned_reviewer VARCHAR(100),
review_date TIMESTAMP WITH TIME ZONE,
approval_date TIMESTAMP WITH TIME ZONE,
rejection_reason TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
n8n Credentials Configuration
This example requires the following credentials to be configured in n8n Credentials:
Credential Type | Purpose | Example Configuration |
---|---|---|
SMTP account | Used to send email notifications related to loan approval, please ensure you have prepared the email account and SMTP server information | ![]() |
Postgres account | Used to store and query loan application records, as well as update application status | ![]() |
OneAI account | Used to call OneAI platform API interfaces | ![]() |
Header Auth account | Used to add security authentication mechanism for Workflow | ![]() |
Azure Open AI account | Used to call Azure OpenAI models | ![]() |
Full Credentials
Getting Started
Below are the main steps to build the Loan Assistant:
- Initialize Knowledge Space
- Create Loan Application Workflow
- Create Loan Query Workflow
- Add Skills
- Configure Chatbot
Initialize Knowledge Space
In the Knowledge Space management interface of OneAI, create a knowledge space.
1. Create Knowledge Space | 2. File Settings |
---|---|
![]() | ![]() |
Upload the explanatory materials of the loan policy to the knowledge space and ensure it can be successfully indexed.
Sample Loan Policy Document
# Commercial Loan Policy
## Loan Amount and Term Regulations
- Minimum loan amount: $100,000 USD
- Maximum loan amount: $10,000,000 USD
- Loan terms are categorized as follows:
- Short-term: 6 months to 1 year
- Medium-term: 1 to 3 years
- Long-term: 3 to 5 years
## Permitted Loan Purposes
The following are approved uses for commercial loans:
- Purchasing equipment or raw materials
- Expanding production scale
- Technical improvement or innovation
- Working capital requirements
## Prohibited Loan Purposes
Loans cannot be used for the following:
- Financial investments (stocks, futures, etc.)
- Real estate speculation
- Repaying loans from other financial institutions
- Any activities prohibited by laws and regulations
Create Loan Query Workflow
Create a workflow named Query Application Process
, set the status to Active
.
Import this workflow via Import from file
: Query Application Process Workflow
Import Workflow
Imported Workflow
Modify and Check
- Check if the Credential configuration of each node is correct and points to the previously configured Credentials
Testing
- Use n8n's mock data and Test workflow features to test and ensure the process executes correctly
Obtain the Path via the Webhook node and save it
Create Loan Application Workflow
Create a workflow named Loan Application
, set the status to Active
.
Import this workflow via Import from file
: Loan Application Workflow
After Import
Check and Adjust
- Check if the Credential configuration of each node is correct and points to the previously configured Credentials
- Modify the sender and recipient email addresses of the email node
Testing
- Use n8n's mock data and Test workflow features to test and ensure the process executes correctly
Obtain the Path via the Webhook node and save it
Add Skills
Add the loan progress query skill Query Loan Application
- If the n8n workflow is set with HTTP Header Auth, please fill in the corresponding Header Auth credentials in the Request header of the skill
- Note to replace
{n8n_domain}
in the OpenAPI Schema with the actual domain name of n8n, and{path}
with the previously saved Webhook Path
OpenAPI Schema Example
Click to view full code
{
"openapi": "3.0.3",
"info": {
"title": "Query Loan Application",
"version": "1.0.0"
},
"servers": [
{
"url": "https://{n8n_domain}"
}
],
"paths": {
"/webhook/{path}": {
"get": {
"operationId": "queryLoanApplication",
"summary": "Query Loan process, status",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"applicationId": {
"type": "string",
"description": "Loan Application Id"
}
},
"required": [
"applicationId"
]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"application_id": {
"type": "string",
"description": "Unique Application ID"
},
"companyName": {
"type": "string",
"description": "Company Name"
},
"contactPerson": {
"type": "string",
"description": "Contact Person Name"
},
"loanAmount": {
"type": "number",
"description": "Loan Amount"
},
"loanTerm": {
"type": "string",
"description": "Loan Term"
},
"purpose": {
"type": "string",
"description": "Loan Purpose"
},
"application_date": {
"type": "string",
"format": "date-time",
"description": "Date when the loan application was submitted"
},
"status": {
"type": "string",
"description": "Current status of the loan application"
},
"review_notes": {
"type": "string",
"description": "Notes from the reviewer about the application"
},
"assigned_reviewer": {
"type": "string",
"description": "Name of the person assigned to review the application"
},
"review_date": {
"type": "string",
"format": "date-time",
"description": "Date when the application was reviewed"
},
"approval_date": {
"type": "string",
"format": "date-time",
"description": "Date when the application was approved"
},
"rejection_reason": {
"type": "string",
"nullable": true,
"description": "Reason for rejection if the application was rejected"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the record was created"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the record was last updated"
}
},
"required": [
"application_id",
"companyName",
"contactPerson",
"loanAmount",
"loanTerm",
"purpose",
"status",
"application_date",
"created_at",
"updated_at"
]
}
}
}
}
}
}
}
}
}
Add the loan application skill Loan Application
- If the n8n workflow is set with HTTP Header Auth, please fill in the corresponding Header Auth credentials in the Request header of the skill
- Note to replace
{n8n_domain}
in the OpenAPI Schema with the actual domain name of n8n, and{path}
with the previously saved Webhook Path
OpenAPI Schema Example
Click to view full code
{
"openapi": "3.0.3",
"info": {
"title": "Loan Application",
"version": "1.0.0"
},
"servers": [
{
"url": "https://{n8n_domain}"
}
],
"paths": {
"/webhook/{path}": {
"post": {
"operationId": "loanApplication",
"summary": "Loan Application",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"companyName": {
"type": "string",
"description": "Company Name"
},
"contactPerson": {
"type": "string",
"description": "Contact Person Name"
},
"loanAmount": {
"type": "number",
"description": "Loan Amount"
},
"loanTerm": {
"type": "string",
"description": "Loan Term"
},
"purpose": {
"type": "string",
"description": "Loan Purpose"
}
},
"required": [
"companyName",
"contactPerson",
"loanAmount",
"loanTerm",
"purpose"
]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"application_id": {
"type": "string",
"description": "Unique Application ID"
},
"companyName": {
"type": "string",
"description": "Company Name"
},
"contactPerson": {
"type": "string",
"description": "Contact Person Name"
},
"loanAmount": {
"type": "number",
"description": "Loan Amount"
},
"loanTerm": {
"type": "string",
"description": "Loan Term"
},
"purpose": {
"type": "string",
"description": "Loan Purpose"
}
},
"required": [
"application_id",
"companyName",
"contactPerson",
"loanAmount",
"loanTerm",
"purpose"
]
}
}
}
}
}
}
}
}
}
Configure Chatbot
Fill in basic information such as Code, Name, and Description.
Welcome messages can use []
to provide some quick questions.
Example
Hello, I am the SWO Bank Loan Assistant. How can I help you today?
[I would like to know the maximum amount for a business loan]
[I want to apply for a business loan]
[I want to check the status of my loan application]
Conversation Settings
- Model: it is recommended to use
gpt-4.1
- Context count: set to maximum
- Suggested questions: turn off
- Prompt: pay attention to guiding the invocation of skills
Example
You are SWO Bank's intelligent loan assistant, equipped with extensive loan knowledge and process guidance capabilities. You will help users complete the following three tasks professionally and accurately based on knowledge base content:
### Your responsibilities include the following three core skills:
### Skill 1: Loan Policy Query
* When users ask questions about loan policies, requirements, or processes, use the `searchHybrid` function to search in the knowledge base.
* If relevant information is found, please **accurately quote the content** in your response.
* If no relevant information is found, please reply: **"No relevant information found. Please contact bank staff."**
* **Prohibited** from making up content or answering based on common sense.
### Skill 2: Loan Application
- When users wish to apply for a loan, please guide them to provide the following information:
Loan application information:
* Company Name
* Contact Person
* Loan Amount
* Loan Term
* Purpose
- After the user provides complete information, call the `loanApplication` function to initiate the loan application and inform the user of the returned application ID (application_id).
### Skill 3: Loan Progress Query
* When users wish to check loan progress, call the `queryLoanApplication` function.
* Guide users to provide the necessary loan number.
* When returning results, inform users about the loan review progress, approval or rejection reasons, and approval time, ensuring content is concise, accurate, and professional.
### Usage Principles
* All answers must be based on knowledge base content or user input, no fabrication allowed.
* Always maintain professional, clear, and polite expression.
* Please do not output superfluous hyperlinks, function names, or square brackets in your answer.
* If there are cited documents, please embed them in the answer in markdown link format at the appropriate location.
* If user's request is unclear, guide them to choose one of the following operations:
* Learn about loan policies
* Initiate loan application
* Check loan progress
Skill Plugins
Add Loan Application and Query Loan Application skills.
Knowledge Source
- Knowledge base: enable
- Knowledge space: select the knowledge space just created
- Retrieval strategy: select intelligent retrieval
- View references: enable