# Lesson 4.3 — Mapping Intents to Data Sources

{% embed url="<https://youtu.be/9O-EAnBzlz8>" %}

### Introduction: Connecting the Dots

In the previous lesson, we meticulously designed our intent taxonomy, creating a structured map of all possible user goals. We now have a clear understanding of *what* our users want to achieve. The next logical step is to determine *where* the answers to their questions can be found. This process is called **intent-to-data-source mapping**.

Intent-to-data-source mapping is the crucial step of connecting each intent in our taxonomy to the specific data source, tool, or agent that is best equipped to handle it. This is where our conceptual blueprint (the taxonomy) becomes an actionable routing plan. A well-executed mapping strategy ensures that every query is not only correctly classified but also efficiently directed to the most relevant and reliable source of information.

This lesson will guide you through the process of creating a comprehensive and effective intent-to-data-source map, transforming your taxonomy into a powerful routing engine.

### The Data Source Landscape

Before we can map intents to data sources, we must first have a clear inventory of all the information and tools available to our AI agent. In a modern enterprise, this landscape can be incredibly diverse.

| Data Source Type         | Description                                                                                 | Examples                                                                           |
| ------------------------ | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **Vector Stores**        | Optimized for semantic search, these are the primary knowledge bases for unstructured text. | Product documentation, FAQs, marketing content, support articles.                  |
| **Structured Databases** | Traditional databases (SQL or NoSQL) that store structured data.                            | Customer records, order information, financial data, inventory levels.             |
| **APIs & Tools**         | Interfaces that allow the agent to interact with other systems and perform actions.         | Placing an order, sending an email, checking a shipping status, booking a meeting. |
| **Other AI Agents**      | Specialized agents with their own unique skills and knowledge bases.                        | A finance agent, a human resources agent, a technical support agent.               |

Creating a comprehensive inventory of all available data sources is a critical prerequisite for effective mapping.

### The Mapping Process: A Step-by-Step Guide

With our intent taxonomy and data source inventory in hand, we can now begin the mapping process. This is a strategic exercise that requires a deep understanding of both user needs and the available information assets.

#### Step 1: Creating the Mapping Matrix

The most effective way to visualize and manage the mapping process is to create a mapping matrix. This is a table that lists all of your intents on one axis and all of your data sources on the other.

<table><thead><tr><th width="118.9140625">INTENT</th><th width="120.55078125">Confidence Gate</th><th>Route Type</th><th>Target Files / Collections</th><th>Filters / Args</th><th>Fallback</th></tr></thead><tbody><tr><td>Get-Order-Status</td><td>≥0.65</td><td>Function</td><td>get_order_status(order_id)</td><td>require: order_id</td><td>ask_for_order_id → escalate</td></tr><tr><td>Refund-Status</td><td>≥0.70</td><td>KB Vector</td><td>refunds_handbook.md, refunds_policy_2023.pdf</td><td>tag=refunds, effective_date>=2023</td><td>function:get_refund_case</td></tr><tr><td>Product-Specs</td><td>≥0.60</td><td>KB Vector</td><td>specs_catalog_2024.pdf, specs/*</td><td>product_id={{pid}}, locale={{lang}}</td><td>catalog_api</td></tr><tr><td>Schedule-Demo</td><td>≥0.80</td><td>Function</td><td>create_demo_meeting()</td><td>require: timezone</td><td>KB: demo_playbook.md</td></tr><tr><td>Out-of-Scope</td><td>n/a</td><td>Escalate</td><td>n/a</td><td>n/a</td><td>human_handoff</td></tr></tbody></table>

#### Step 2: Assigning Primary and Secondary Sources

For each intent, identify the **primary** data source that is most likely to contain the answer. This is the first place the router will look. In some cases, it may also be useful to identify **secondary** or **fallback** sources that can be consulted if the primary source does not yield a satisfactory result.

In the example above, a query with the intent `product.specifications` would first be routed to the "Product Docs" vector store. If no answer is found, it might then fall back to the "FAQs" vector store.

#### Step 3: Handling Multi-Source Intents

Some intents may require information from multiple sources. For example, to answer an `order.track` query, the agent might need to retrieve the order details from the "Orders" database and then use the tracking number to call the "Shipping" API. Your mapping should account for these multi-step workflows.

#### Step 4: Documenting the Rationale

For each mapping decision, it is important to document the rationale behind it. Why is the "Product Docs" vector store the primary source for `product.specifications`? What specific information is expected from the "Shipping" API? This documentation is invaluable for maintaining and updating the routing system over time.

### Conclusion: From Blueprint to Action Plan

Intent-to-data-source mapping is the bridge between understanding user needs and fulfilling them. It transforms our abstract intent taxonomy into a concrete, actionable plan for our routing system. By carefully mapping each intent to the most appropriate data source, we ensure that our AI agent can efficiently and accurately find the information it needs to provide helpful and relevant responses.

In the next lesson, we will address the inevitable complexities of a real-world system: **conflict resolution and fallbacks**. We will explore how to handle situations where an intent is ambiguous or where the primary data source fails to provide an answer.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.raiaai.com/ai-training/ai-training/how-to-train-an-ai-agent/module-4-routing-and-intent-mapping/lesson-4.3-mapping-intents-to-data-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
