How to Connect an AI Assistant to Bank Accounts for Read-Only Natural Language Financial Queries

    This article explains how to build an AI assistant that answers natural language questions about bank, credit card, and payment data while staying strictly read-only. It covers the technical motivation, why read-only access is a first-class design decision, a four-layer account aggregation architecture (interaction, orchestration, data gateway, and data source layers), the intent-recognition and query-orchestration pipeline with sample code, privacy and compliance mechanisms, and the key engineering tradeoffs around performance, accuracy, fault tolerance, observability, and clear disclaimers.

    1. Technical Background: From App Switching to a Single Query

    Personal financial management has a simple but stubborn pain point: a user’s assets, liabilities, and spending data are scattered across multiple bank accounts, credit card accounts, and payment channels. Checking a balance, reconciling transactions, or summarizing spending usually requires logging in to each source and switching back and forth repeatedly.

    Once large language model assistants gained natural language understanding, a natural product idea emerged: could a user get a unified, cross-account answer with a single sentence, such as “How much did I spend on dining this month?” or “How much do I owe on each of my two credit cards?”

    The technical core of this capability is not “chat.” It is securely mapping an unstructured natural language request to a structured query against controlled data. Understanding this is the prerequisite for designing a trustworthy system: the assistant itself holds no funds and has no authority over the data. It is better understood as a strictly constrained “query proxy layer.”

    2. Capability Boundaries: Why Read-Only Access Comes First

    Any system that touches real money must treat its permission model as a primary design concern, not an afterthought. There is one key principle here: reading information and moving money should be fully decoupled.

    • Read-only: The assistant retrieves only query-type data such as account balances, transaction records, and repayment amounts, for answering and analysis.
    • No-write: The assistant cannot initiate transfers, debits, automatic deductions, card binding changes, or credit limit adjustments.
    • No substitution for user decisions: The assistant provides information summaries and trend analysis, rather than executing financial actions on the user’s behalf.

    Confining the system strictly to a “read-only information query and analysis tool” narrows the potential risk surface from “loss of funds” to the single category of “information exposure.” The latter can be systematically contained through encryption, data masking, least privilege, and auditing. In other words, read-only is not a lack of capability; it is a deliberate security trade-off.

    3. Data Access Architecture: A Four-Layer Model for Account Aggregation

    To bring scattered account data into a single, queryable view, the industry commonly uses a layered, decoupled architecture. Below is a general reference model (layer names are illustrative, not tied to any specific product API):

    1. ┌─────────────────────────────────────────────┐
    2. │ ① Interaction Layer: conversational entry / │
    3. │ intent clarification │
    4. ├─────────────────────────────────────────────┤
    5. │ ② Orchestration Layer: intent detection → │
    6. │ query plan → result composition │
    7. ├─────────────────────────────────────────────┤
    8. │ ③ Data Gateway Layer: account connectivity, │
    9. │ token management, rate limiting, breaking │
    10. ├─────────────────────────────────────────────┤
    11. │ ④ Data Source Layer: bank / card / channel │
    12. │ accounts (via authorized APIs) │
    13. └─────────────────────────────────────────────┘

    ① Interaction Layer collects the user request and asks for clarification when intent is ambiguous (for example, whether “account” means a savings card or a credit card).

    ② Orchestration Layer is the core. It parses natural language into an executable query plan, dispatches requests to the data gateway, and organizes the returned structured results into a human-readable answer.

    ③ Data Gateway Layer handles the common capabilities needed to connect to external data sources, including acquiring and refreshing authorization tokens, request rate limiting, failure circuit-breaking, data caching, and unified format conversion. In the cloud, these capabilities are typically provided by common components such as API gateways, message queues, object storage, and monitoring and alerting, which ensure the stability and observability of the integration.

    ④ Data Source Layer relies, in financial scenarios, on general approaches such as “open banking / account aggregation”: the user grants a one-time authorization that lets a third party read their account information within a restricted scope. Authorization is typically granted as a short-lived token that the user can revoke at any time.

    4. Intent Recognition and Query Orchestration Pipeline

    Converting natural language into a data query is the most technically demanding part of the entire pipeline. A robust implementation usually includes the following steps:

    1. Intent recognition: Determine whether the user wants to query a “balance,” “transaction records,” “spending broken down by category,” or a “cross-account summary.”
    2. Entity extraction: Extract key parameters such as time range, account identifier, amount, and spending category.
    3. Query plan generation: Map the intent and entities to a set of supported structured queries (rather than arbitrary SQL), preventing injection and privilege escalation.
    4. Security validation: Verify that the request falls within the authorized scope (account scope, field scope, time range).
    5. Result composition and explanation: Convert the structured data into natural language, providing a note on the statistical basis where necessary.

    The following is illustrative code showing the idea of “constrained query orchestration + read-only validation + audit logging” (pseudocode, provided only to explain the design, not representing any real API):

    1. # Read-only allowlist: the orchestration layer may only call these query capabilities
    2. READ_ONLY_QUERIES = {
    3. "get_balance": "Query the balance of a specified account",
    4. "get_transactions": "Query transactions within a time range",
    5. "spend_by_category":"Aggregate spending statistics by category",
    6. }
    7. def handle_query(user_input, session):
    8. # 1) Intent recognition + entity extraction (done jointly by the language model and rules)
    9. intent, entities = parse_intent(user_input)
    10. # 2) Privilege protection: reject anything not on the read-only allowlist
    11. if intent not in READ_ONLY_QUERIES:
    12. raise PermissionError(f"Unsupported operation: {intent}")
    13. # 3) Authorization scope check: only access accounts and time windows the user authorized
    14. accounts = session.authorized_accounts # account set limited by the authorization token
    15. if not set(entities.get("accounts", [])) <= set(accounts):
    16. raise PermissionError("Request exceeds the authorized account scope")
    17. # 4) Execute the read-only query (no write-operation branch exists)
    18. result = query_gateway.execute(intent, entities, scope=accounts)
    19. # 5) Full audit: who, when, what was queried, and the scope of results
    20. audit_log.record(
    21. user=session.user_id,
    22. intent=intent,
    23. entities=entities,
    24. result_summary=summarize(result),
    25. )
    26. return naturalize(result) # compose the result into a natural language answer

    This code demonstrates three engineering points: a capability allowlist (write operations have no entry point at all), authorization scope validation (users can only read their own authorized data), and full auditing (every query is traceable). Together they form a closed loop of “read-only, controlled, and auditable.”

    5. Privacy and Compliance: The Baseline for a Trustworthy System

    Financial data is highly sensitive personal information, so privacy protection is not a bonus feature but an entry requirement. The following general mechanisms must be built in:

    • Least-necessary principle: Read only the fields required to answer the question; aggregate rather than return line items where possible, and mask rather than expose raw values where possible.
    • Data encryption: Encrypt data in transit, and apply encryption with separated key management for data at rest.
    • Token-based authorization: Access data with short-lived, revocable tokens so users can disconnect and reclaim access at any time.
    • Explainability and revocability: Users can see “what the assistant read and when,” and can revoke authorization with a single action.
    • Access auditing and alerting: Abnormal access (high-frequency queries, privilege escalation attempts) should trigger monitoring alerts and rate limiting.
    • No secondary use of data: Data that is read is used only to answer the user’s question and for no other purpose, unless separate, explicit authorization is obtained.

    When implementing these in the cloud, such capabilities are typically assembled from general cloud components such as key management services, logging services, monitoring and alerting, and identity and access management. For example, developers using general capabilities from a cloud provider such as Baidu AI Cloud can build a compliant read path on top of its identity and permission management, logging and monitoring, and encryption key components; the specific selection should be evaluated against your own compliance requirements and scenario.

    6. Key Engineering Trade-offs

    Bringing this design into production requires attention to a few engineering issues that are easy to overlook:

    • Balancing performance and experience: Account aggregation involves multiple external calls, so use caching, asynchronous orchestration, and result prefetching to reduce latency; meanwhile, “loading” feedback keeps the conversation feeling smooth.
    • Accuracy and consistent definitions: Spending statistics must clearly define the time interval, whether refunds are included, currency, and rounding rules, to avoid misunderstandings caused by inconsistent definitions.
    • Fault tolerance and degradation: When an external data source is unavailable, clearly tell the user that “some accounts are temporarily unreadable” rather than silently returning incomplete results.
    • Observability: Establish metrics for each query pipeline (success rate, latency, number of privilege-escalation blocks) to support continuous improvement.
    • Clear disclaimers: The assistant provides information and analysis, not investment advice or fund operations; this should be clearly expressed in both the interface and the wording.

    7. Summary

    Connecting an AI assistant to bank accounts for natural language financial queries is, at its core, a problem of a constrained information proxy. Technically, it requires reliably mapping natural language to structured queries. On security, it defines boundaries through read-only access, token-based authorization, and full auditing. On compliance, it protects highly sensitive data through the least-necessary principle, encryption, and revocability. Fully decoupling fund operations from information reading, restricting permissions to a read-only allowlist, and bringing every access under audit—these three points are the real foundation for this kind of capability being worthy of a user’s trust.