How to Integrate LangChain for retail banking with Slack for multi-agent systems
Combining LangChain for retail banking with Slack gives you a clean control plane for human-in-the-loop banking agents. The pattern is simple: LangChain handles retrieval, policy checks, and agent orchestration; Slack becomes the operator interface for alerts, approvals, and exception handling.
Prerequisites
- •Python 3.10+
- •A Slack workspace with permission to create an app
- •A Slack bot token and signing secret
- •Access to your banking knowledge base, policy docs, or internal APIs
- •LangChain installed with the packages you use for your model and tools
- •Environment variables configured:
- •
SLACK_BOT_TOKEN - •
SLACK_APP_TOKENif using Socket Mode - •
OPENAI_API_KEYor your model provider key - •Any bank API credentials you need for downstream actions
- •
Install the core dependencies:
pip install langchain langchain-openai slack-bolt slack-sdk python-dotenv
Integration Steps
- •Set up the LangChain retail banking agent
Start by building the banking agent as a normal LangChain pipeline. In production, this usually means retrieval over product docs, AML/KYC policies, fee schedules, and account servicing workflows.
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.tools import tool
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
@tool
def lookup_fee_policy(query: str) -> str:
"""Return bank fee policy guidance for a customer query."""
policies = {
"overdraft": "Overdraft fee is $35 per item. Maximum 3 fees per day.",
"wire transfer": "Outgoing domestic wire fee is $25.",
}
return policies.get(query.lower(), "No matching policy found.")
prompt = ChatPromptTemplate.from_messages([
("system", "You are a retail banking assistant. Follow bank policy exactly."),
("human", "{input}")
])
agent_chain = prompt | llm.bind_tools([lookup_fee_policy])
- •Create a Slack app and wire in event handling
Use Slack Bolt to receive messages from a channel like #banking-ops. For multi-agent systems, this channel often acts as the dispatch layer where humans post requests and agents respond.
import os
from slack_bolt import App
app = App(token=os.environ["SLACK_BOT_TOKEN"])
@app.event("message")
def handle_message_events(body, say):
event = body.get("event", {})
text = event.get("text", "")
user = event.get("user", "")
if user and text:
say(f"Received request: {text}")
- •Connect Slack messages to the LangChain chain
This is the core integration. Take the Slack message text, pass it into your LangChain chain, then send the result back to Slack.
@app.event("message")
def handle_message_events(body, say):
event = body.get("event", {})
text = event.get("text", "")
user = event.get("user", "")
if not user or not text:
return
result = agent_chain.invoke({"input": text})
# result may be an AIMessage or structured tool output depending on your chain
response_text = getattr(result, "content", str(result))
say(f"Banking agent response: {response_text}")
If you want cleaner multi-agent routing, add a classifier step before the main chain. One agent can triage customer-service questions while another handles operations requests.
from langchain_core.runnables import RunnableLambda
def route_request(payload: dict):
text = payload["input"].lower()
if "fee" in text or "charge" in text:
return {"input": f"Use policy lookup for: {payload['input']}"}
return {"input": payload["input"]}
routed_chain = RunnableLambda(route_request) | agent_chain
@app.event("message")
def handle_message_events(body, say):
event = body.get("event", {})
text = event.get("text", "")
if text:
result = routed_chain.invoke({"input": text})
say(getattr(result, "content", str(result)))
- •Add structured approvals for sensitive actions
For retail banking, don’t let the model execute anything sensitive without human approval. Use Slack threads or interactive buttons to confirm actions like card reissue requests or limit changes.
from slack_sdk import WebClient
client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
def request_approval(channel_id: str, message_ts: str, summary: str):
client.chat_postMessage(
channel=channel_id,
thread_ts=message_ts,
text=f"Approval required:\n{summary}\nReply with APPROVE or REJECT."
)
Then gate execution in your application logic:
def execute_sensitive_action(customer_id: str):
# Replace with internal bank API call.
return f"Sensitive action executed for customer {customer_id}"
@app.event("message")
def handle_message_events(body, say):
event = body.get("event", {})
text = event.get("text", "")
channel_id = event.get("channel")
ts = event.get("ts")
if "freeze card" in text.lower():
request_approval(channel_id, ts, f"Freeze card request detected: {text}")
return
result = agent_chain.invoke({"input": text})
say(getattr(result, "content", str(result)))
- •Run the Slack app in Socket Mode
Socket Mode avoids exposing a public HTTP endpoint during development and works well for internal tooling.
from slack_bolt.adapter.socket_mode import SocketModeHandler
if __name__ == "__main__":
handler = SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"])
handler.start()
Testing the Integration
Send a message in your Slack channel like:
What is the overdraft fee?
Your bot should route that into LangChain and return the policy response.
test_result = agent_chain.invoke({"input": "What is the overdraft fee?"})
print(getattr(test_result, "content", str(test_result)))
Expected output:
Overdraft fee is $35 per item. Maximum 3 fees per day.
If you test the Slack path end-to-end, you should see:
- •Bot receives the message in Slack
- •LangChain evaluates the query
- •The response appears in the same channel or thread
Real-World Use Cases
- •Branch ops assistant: Triage service requests from bankers in Slack and route them to specialized LangChain agents for fees, disputes, card servicing, or lending questions.
- •Policy approval workflow: Use Slack threads for approvals when an agent proposes a sensitive action like account freeze escalation or limit increase.
- •Internal knowledge concierge: Let employees ask compliance-safe questions in Slack while LangChain retrieves answers from approved retail banking documentation.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit