Skip to main content

Build Your First AI Agent (Step-by-Step)

Create, train, and deploy your first AI Agent in under 5 minutes. This guide covers everything from setting up the AI brains to going live on Telegram.

In just a few minutes, you'll have a fully functional AI Agent trained on your specific business data. Let's follow the logical flow of building a professional agent.

Overview of the Workflow

To build a complete agent, we follow these 5 essential steps:

1. Setup Embedding Model

Prepare the search engine that will understand and "read" your data.

2. Initialize Knowledge Base

Upload your documents and train the agent on your facts.

3. Configure Dialogue Model (LLM)

Setup the conversational brain (the model that talks to users).

4. Construct the Pipeline

Connect the models and knowledge into a single processing unit.

5. Deploy your Bot

Connect your pipeline to a platform like Telegram.


Step 1: Setup Embedding Model (The Search Engine)

Embedding models are used to compute vector representations of messages. If you wish to use a Knowledge Base, you must configure an embedding model first.

Navigate to Models > Embedding Models and click Add New Model.

Setup Embedding Model

Then select Fahemdb-built-in as the provider to simplify the process.

Select Fahemdb Provider

Option A: Using Built-in Model (Zero Configuration)

The system integrates an official embedding model (Fahemdb-built-in) that requires no parameters or API keys.

  1. On the "Embedding Model" page, select Fahemdb-built-in.
  2. Click Save to use it immediately.
  3. Later, select this model when creating your Knowledge Base.

Option B: Custom Embedding Model

To use an external provider (like Google Gemini), you will need to enter these four parameters: Model Name, Model Provider, Request URL, and API Key. After submitting, you can select it in your knowledge base.

Configure Custom Embedding Model

Step 2: Initialize Knowledge Base

Now that we have the search engine ready, let's feed your agent some information.

  1. Go to the Knowledge section in the sidebar.
  2. Click the + (Plus) button and give your KB a name (e.g., "Company FAQ").
  3. Crucial: Select the Embedding Model you configured in Step 1.
Define Knowledge Base Name and select Model

Add Training Data

You can now upload your files or text:

Upload PDFs or Word docs.

Uploading Files

Step 3: Configure Dialogue Model (The Brain)

This is the Large Language Model (LLM) that will actually speak to your users.

  1. Go to Models > LLM Models.
  2. Click Add New Model.
  3. Select a provider (e.g., OpenAI, Groq) and enter your API Key.
  4. Set the Model Name (e.g., gpt-4o or llama-3.1-70b).
Configure LLM Model Details

Step 4: Construct the Pipeline (The Logic)

The Pipeline is the "glue" that connects your Knowledge Base and your LLM brain. It defines the flow of information.

Access Pipelines

Navigate to Pipelines in the sidebar. You can use the Default Pipeline or create a new one.

Pipelines Section

Configure AI & Model

In the AI tab, set the runner to Local Agent and select the Dialogue Model you configured in Step 3.

Configure Runner and Model

Set Personality (Prompt)

Define the Prompt to give your agent a specific identity and set of rules (e.g., "You are a professional support agent for FahemAI").

Setting the System Prompt

Attach Knowledge

Click + Add Knowledge Base and select the "Company FAQ" KB we created in Step 2. This ensures the agent uses your data to answer.

Linking Knowledge Base to Pipeline
info

FahemAI will use the Knowledge Base to find facts and then use the LLM to write a friendly response to the user.


Step 5: Deploy your Bot (Telegram Example)

The final step! Let's connect your AI Pipeline to a real messaging platform.

Create your Telegram Bot

  1. Open Telegram and search for @BotFather.
  2. Send the command /newbot.
  3. Follow the instructions to give your bot a Name and a Username (must end in _bot).
  4. Copy the API Token provided at the end. You'll need this to connect to FahemAI.
Getting API Token from BotFather

Add Telegram Integration in FahemAI

  1. Navigate to Connect > Integrations in the sidebar.
  2. Click on the Telegram icon or button.
  3. In the "Create Bot" modal, enter a Name and Description for your bot.
  4. Paste the API Token you got from BotFather into the corresponding field.
  5. Click Submit.
Creating Telegram Bot Integration

Link your Pipeline

  1. Once the bot is created, click on Settings (or the Edit icon) for your new Telegram bot.
  2. Choose Pipeline: Select the pipeline you configured in Step 4 from the dropdown menu. This links your AI logic to this specific Telegram account.
  3. Click Save or Update.
Binding Pipeline to Bot

Test it Live!

Open your bot on Telegram and send a message like "Hello" or ask a question about your knowledge base. Your AI Agent will process the message through the pipeline and respond instantly.

Bot Working on Telegram

🎉 You're Done!

You have successfully built a professional, RAG-powered (Retrieval-Augmented Generation) AI agent.

Success

Knowledge Base trained on your data.

Success

Pipeline configured with high-performance models.

Success

Bot live on Telegram.