> For the complete documentation index, see [llms.txt](https://docs.chord.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chord.co/analyze-with-ai/context.md).

# Context

## Context

## Introduction

![](https://2938842758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5Oy2IAsu7IvAGAlWgC36%2Fuploads%2Fgit-blob-fe5287f1cb1c1533417f34a73c8f9beddc8ac232%2Fcontext-1.png?alt=media)

Context helps you capture and manage verified insights in the form of **Instructions** and **SQL Pairs**.

**Instructions** offer two levels of guidance:

* **Global Instructions**, which apply to all queries (e.g., applying business rules like filtering out canceled orders, enforcing rounding conventions or naming standards across the board), and
* **Question‑Matching Instructions**, which apply only when a question matches a defined pattern (e.g., how to calculate “late delivery rate” based on specific date logic).

Together, these ensure more precise, standardized SQL generation aligned with your organization’s metrics and logic.

Additionally, **SQL Pairs** allow you to map natural language questions like “What is our average customer lifetime value?” to pre‑verified SQL queries, so that when similar questions are asked in the future, Ask Chord can generate accurate and consistent results using those saved queries.

Question types that are best served by **SQL Pairs** include:

* Complex business or computation logic that requires precise SQL formulation.
* Frequently asked business questions with established calculation methods.
* Custom KPIs and metrics specific to your brand.

Combined, **Instructions** and **SQL Pairs** give Ask Chord the ability to answer domain-specific questions with high consistency and accuracy, capturing organizational knowledge, reducing SQL errors, and improving trust in AI-generated outputs.

Read on for additional information about these features within Chord Context.

### Instructions

![](https://2938842758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5Oy2IAsu7IvAGAlWgC36%2Fuploads%2Fgit-blob-3e9dd2adf7e42a27fd26501b1182ada38c2019f9%2Fcontext-2.png?alt=media)

The **Instructions** feature lets your team embed business logic and formatting rules directly into how the system generates SQL queries and answers. By using Instructions, organizations can standardize how metrics are calculated, ensure consistent SQL structure, and provide data context in a way that aligns closely with internal definitions. It helps Ask Chord produce accurate, reliable, and predictable answers by capturing domain-specific business rules and metrics logic in advance.

There are two types of **Instructions** that organizations can customize: **Global Instructions** and **Question-Matching Instructions**.

#### Global instructions

You can set **Global Instructions** that apply to all questions, perfect for enforcing naming conventions, consistent rounding, data filters (e.g. excluding canceled orders), and join behaviors.

To add a **Global Instruction**:

1. Navigate to the **Context** navigation link.
2. Click the **"Add Instruction"** button.
3. Select **"Global"** under **"Apply instruction to"**.
4. Enter your instruction details in the text field.
5. Click\*\* "Submit"\*\* to save and apply the instruction.

#### Question-matching instructions

You can also define **Question-Matching Instructions**, which only apply when user queries match specific patterns or topics such as calculating “late delivery rate” using your exact definition.

To add a\*\* Question-Matching Instruction\*\*:

1. Navigate to the **Context** navigation link.
2. Click on the **Instructions** tab.
3. Click the\*\* "Add Instruction"\*\* button.
4. Select **"Matched to specific questions"** under **"Apply instruction to".**
5. Enter your instruction details in the text field.
6. Add questions that should trigger the instruction.
7. Click **"Submit"** to save and apply the instruction.

### SQL pairs

![](https://2938842758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5Oy2IAsu7IvAGAlWgC36%2Fuploads%2Fgit-blob-999e15b5cb6bd5a16876e4277436e1ceff382018%2Fcontext-3.png?alt=media)

**SQL Pairs** capability allows you to capture and map natural‑language questions to their exact SQL queries, building a trusted knowledge base of verified answers. Whenever a team member asks a similar question such as "What is our average order value?", Ask Chord can pull the saved SQL and respond with the exact computation each time, ensuring consistency across the organization.

To set up a **SQL Pair**, you can manually add a SQL pair to Chord Context if you know certain questions that your team will ask in advance.

To manually add a **SQL Pair**:

1. Navigate to the **Context** navigation link.
2. Click on the **Question-SQL Pairs** tab.
3. Click the\*\* "Add Question-SQL Pair"\*\* button.
4. Add a question and the corresponding SQL statement that answers the quesiton.
5. Click **"Create"** to create and save the SQL Pair.

Once a SQL Pair is created, you can view, edit, or delete a specific SQL Pair at any time.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chord.co/analyze-with-ai/context.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
