Sitemap

Finycs Chatbot with Agentic AI Using LangGraph

3 min readOct 28, 2025

Introduction: The Finycs Chatbot

The Finycs chatbot is an agentic financial assistant built using LangGraph which allows users to interact with complex accounting data using natural language. Users can ask questions about transactions, revenues, expenses, or other business metrics, and the chatbot translates those queries into SQL commands, executes them, and returns both textual insights and interactive visualizations.

What is LangGraph?

LangGraph is a framework built on top of LangChain that lets you design AI workflows as directed graphs — where each node represents a reasoning or tool step, and edges define how outputs flow between them.

LangGraph systems are built from three core components: nodes, edges, and state

1. Nodes

A node represents a single unit of computation or reasoning — for example, an LLM call, a database query, or a function that transforms intermediate results.

2. Edges

Edges define the directed flow between nodes — they determine how and when data moves through the graph.

3. State

State is the shared memory or context that persists across nodes. It holds:

  • User inputs
  • Intermediate reasoning results (like generated SQL)
  • Execution outputs
  • Conversation history

Graph Architecture of the Chatbot:

Architectural Overview: Multi-Agent System

The chatbot architecture uses a hierarchical multi-agent pattern, where specialized agents operate under the coordination of a central supervisor. This design helps brings organization and efficiency to complex interactions while maintaining clear separation of concerns.

Dynamic Routing with Conditional Edges

graph_builder.add_conditional_edges(
"query_validation_node",
graph_routers.route_query_validation,
{
"valid": "ask_agent_node",
"invalid": "handle_query_validation_fails"
}
)

The system comprises several key components working together. At the entry point, a Query Validation Node serves as the first line of defense, sanitizing user input and verifying that queries are legitimate business questions rather than malicious attempts at SQL injection or system manipulation. This validation step removes dangerous characters, normalizes Unicode, and checks against patterns commonly associated with security threats.

Once validated, queries flows to the ask agent node — the orchestration layer when the supervisor agent and all other agent are present. The supervisor agent makes routing decisions based on query classification. The supervisor analyzes whether a query requires database access or can be handled directly (for instance, greetings, help requests, or general information). This hierarchical coordination pattern ensures that specialized agents receive only the tasks they’re designed to handle, improving efficiency and security.

When database access is required, the Database Agent takes over. This specialized agent has two execution paths:

  • Use prebuilt query tool functions for common business questions, or
  • Dynamically generate SQL for new or complex requests

it can invoke pre-built query tool functions if the user query aligns with the prebuilt tools functions scope (providing faster responses for common queries), or it can dynamically generate SQL queries using natural language understanding for questions that can’t be answered using the query tool functions. The agent follows a systematic approach: examining available tables, inspecting relevant schemas, constructing syntactically correct SQL, validating the query for errors, and finally executing it against the database.

State Management:

The chatbot state captures all necessary information for processing user queries and maintaining conversation context.

The state includes user information (authentication details, permissions), business context (which company’s data to query, fiscal year settings, timezone), chat session data , and processing artifacts (the current query, generated SQL, execution results, and formatted responses). This state travels through the graph as nodes process it, with each node reading relevant portions and updating specific fields.

Enabling Analytical Insights: Table and Graphs

A key differentiator of this chatbot is that it can present data through visualizations and structured formats, not just text. The chatbot shows data in markdown tabular format and chooses appropriate graphs for presenting data when required.

When the Database Agent executes a query and receives tabular results, it analyzes the data structure to determine appropriate visualizations.

  • Line charts for time-series data (monthly revenue, quarterly expenses)
  • Bar charts for categorical comparisons (revenue by department, top products)
  • Pie charts for proportions or breakdowns (expense breakdown by category)

The LLM generates chart configurations in a standardized JSON format that the frontend can render using Highcharts library. For example, when a user asks “Show me monthly revenue for 2024,” the chatbot not only returns text (“Revenue grew steadily from 120K in January to 185K in December”) but also provides a line chart configuration that the React frontend renders as an interactive visualization.​

--

--

Artdex & Cognoscis
Artdex & Cognoscis

Written by Artdex & Cognoscis

Official blog of Artdex & Cognoscis Technologies

No responses yet