# Building a AI agent

AI agents are all the rage these days, thanks to ChatGPT.&#x20;

ChatGPT has opened a new way of asking questions and getting answers – that are accurate, brief, and quick.

{% embed url="<https://youtu.be/GMSSzHn9wlU?si=XOAXusDfF9tf9Yba>" %}

Here are the steps to build your own AI agents:

## Step 1: Creating a bot

Next, we need to build a bot that will speak with the visitor and use this knowledge base to fetch the answers to questions asked.

Go to Bot Builder > Build a bot > Inbound > Web

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

## Step 2: Creating a AI agent block

Choose the "AI agent" block from the list and create a new AI agent from the right panel.

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

## Step 3: Setting up the AI agent

The fundamentals of an AI agents are — Prompt, Functions, Paths, LLM settings.

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

### Prompt

A prompt guides the AI on how you want the answer to be generated. Write a clear and concise instruction. Or you can use the "Generate prompt" button to get it auto-generated for you.

[Learn more](/build/prompts.md)

### Functions

Function allow the AI agent to dynamically execute a function to provide contexual responses. For example, you can create function to "fetch order status", "cancel a order" etc which allow the conversation to feel more natural and powerful.

[Learn more](/build/functions.md)

### Paths

By default, the AI agent will run on a loop, answering any question it is asked. But if you want the AI agent to come outside of the execution loop, you can define paths.&#x20;

Each path consists of a name, and a description that lets the AI know when should it take this path.

Every path you create displays a path on the canvas.

### LLM settings

Depending on the scope of your project, you can choose the LLM model you prefer to use along with the max tokens used to provide a response and the temperature for the creativity in responses.

For each response the AI agent generates, a AI credit is consumed. Some models consume more credits while some less.

[Learn more about AI credits](/build/ai-credits.md)

## Step 4: Creating a knowledge base

Let's build a knowledge base, so the AI agent always refers to it when trying to generate an answer to a question.

* Enable the "Use data from knowledge base" on the right panel
* Create a Knowledge base&#x20;
* Start adding data sources

[Learn more about knowledge base](/build/knowledge-base.md)

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

{% hint style="info" %}
**NOTE:**&#x20;

* More data sources, enable more accurate responses.
* Train your website for more context about your business.
* [Setup refresh frequency](/build/knowledge-base/refresh-frequency.md) for your website data sources, so that it is always up-to-date.
  {% endhint %}

## Step 5: Add your flow

Feel free to add more blocks if you have chosen to add paths in your AI agent.&#x20;


---

# 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://help.wotnot.io/getting-started/building-a-ai-agent.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.
