> For the complete documentation index, see [llms.txt](https://docs.agentalk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentalk.io/knowledge-base/connect-a-knowledge-base-to-an-agent.md).

# Connect a knowledge base to an agent

Once a knowledge base is created and trained, you can connect it to an agent from the agent’s settings. After connecting it, the agent can search the knowledge base during a call to answer questions based on your content.

### Before you start

You need the following before you begin:

* A knowledge base with at least one source in **Ready** status. See [**Set up a knowledge base**](/knowledge-base/set-up-a-knowledge-base.md) if you haven't done this yet.
* An existing agent to connect. See [**Create an agent**](/ai-agents/create-an-agent.md).

Follow these steps to connect a knowledge base to your agent.

{% stepper %}
{% step %}

### Open the agent settings

Start by opening the agent you want to configure.

1. Go to **AI Agents** from the sidebar.
2. Select the agent you want to configure.
3. In the Basic Settings, scroll to **Additional Settings** and expand the section.
   {% endstep %}

{% step %}

### Select the knowledge base

Choose which knowledge base the agent should use.

1. Locate the **Knowledge base** dropdown
2. Select a knowledge base

{% hint style="info" %} <mark style="color:$info;">**Knowledge base limit**</mark>

An agent can be connected to only one knowledge base at a time.
{% endhint %}
{% endstep %}

{% step %}

### Test the connection

Verify the agent can use the knowledge base during a call.

1. Click **Save and test agent** to start a test call.
2. Ask a question related to your content

Confirm that:

* The agent retrieves a relevant answer.
* The response is accurate.
* The response time is appropriate.

If the agent does not respond as expected, check:

* The knowledge base status is **Ready.**
* The question is covered in the content.
* The agent instructions allow using the knowledge base.

After testing, make sure to save your changes so they are applied to the agent.
{% endstep %}

{% step %}

### Save the changes

Apply your configuration.

1. Click **Save** to apply changes.
   {% endstep %}
   {% endstepper %}

<figure><img src="/files/Ub3LXSP2aKAwP2xjeyh2" alt=""><figcaption></figcaption></figure>

### Next steps

Here are the recommended next steps after completing this guide:

* [**Set up a knowledge base**](/knowledge-base/set-up-a-knowledge-base.md): Create and prepare content for your agent to use.
* [**Write effective agent instructions**](/ai-agents/write-effective-agent-instructions.md): Guide how the agent uses knowledge base responses in conversations.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.agentalk.io/knowledge-base/connect-a-knowledge-base-to-an-agent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
