# Creating Agents

Paal AI enables users to create custom agents to enhance workflows, automate tasks, and integrate external systems. Agents can be REST API agents, knowledge-based agents, or IoT (MQTT) agents. This documentation provides a comprehensive guide to creating and deploying agents.

***

### **Types of Agents**

#### **1. REST API Agent**

* **Purpose**: Integrate external APIs to execute custom actions or automate workflows.
* **Examples**: CRM integration, stock price fetching, email automation.

#### **2. Knowledge Base Agent**

* **Purpose**: Store and retrieve data from documents, audio, or videos to generate responses.
* **Examples**: Summarize uploaded documents, answer queries from uploaded datasets.

#### **3. IoT (MQTT) Agent**

* **Purpose**: Interact with IoT devices for real-time data collection and control.
* **Examples**: Manage smart devices, monitor environmental conditions.

***

### **Steps to Create an Agent**

#### **Step 1: Choose Agent Type**

1. Navigate to **"Create Agent"**.
2. Select the agent type:
   * **REST API Agent**: Integrate external APIs.
   * **Knowledge Base Agent**: Use uploaded data to create a responsive agent.
   * **IoT (MQTT) Agent**: Set up for IoT device interaction.
3. Click **Next** to proceed.

***

#### **Step 2: Configure Basic Agent Details**

1. **Agent Name**:
   * Assign a descriptive name (e.g., "Stock Price Fetcher").
2. **Agent Icon**:
   * Upload an image to represent the agent visually.
3. **Agent Type**:
   * Select from Chat Agent or File Agent based on the agent's purpose.
4. **Agent Category**:
   * Assign a category for organization (e.g., Finance, Health, Data Analytics).
5. **Description**:
   * Briefly describe what the agent does (e.g., "Fetches stock prices via API").
6. **Conversation Starters**:
   * Add sample prompts or commands to guide user interaction (e.g., “Fetch the latest BTC price”).

***

#### **Step 3: Configurations**

**For REST API Agents**

1. **Operation ID**:
   * Define the action the agent will perform.
2. **Keys and Authentication**:
   * Add required fields such as API keys, tokens, headers, or query parameters.
   * Specify if the fields are required or should be masked for security.
3. **OpenAPI Schema**:
   * Import schema details from a URL or upload a JSON file to define API endpoints and capabilities.

**For Knowledge Base Agents**

1. **Upload Knowledge Files**:
   * Add documents, videos, or audio files.
   * Supported formats: PDF, TXT, DOCX, MP4, MP3, and more.
2. **Knowledge Scope**:
   * Define whether the uploaded content will be global or specific to the agent.
3. **Privacy Policy**:
   * Add terms to ensure data privacy compliance.

**For IoT (MQTT) Agents**

1. **Configure MQTT Credentials**:
   * Set up broker details and credentials for device communication.
2. **Topics**:
   * Define MQTT topics for publishing or subscribing to device data.
3. **Schema**:
   * Add a schema to specify device interactions (e.g., set temperature, turn on lights).

***

#### **Step 4: Advanced Settings**

1. **Configurations Fields**:
   * Add custom fields like API endpoints, environment variables, or user-defined parameters.
2. **Scope**:
   * Choose whether the configuration is creator-defined or user-specific.
3. **Error Handling**:
   * Add fallback actions for scenarios where the agent cannot complete a task.

***

#### **Step 5: Test and Deploy**

1. **Test**:
   * Validate the agent using sample prompts or API calls.
   * Adjust configurations if necessary.
2. **Deploy**:
   * Click **Deploy** to make the agent available in the **My Agents** section.
3. **Post-Deployment Actions**:
   * Assign the agent to workflows or integrate it using its unique Agent ID.

***

### **Examples of Agents**

#### **REST API Agent Example**

* **Name**: "Stock Price Fetcher"
* **Use Case**:
  * Fetch stock prices from a financial API.
  * Combine data with LLM prompts to generate daily financial insights.
* **Workflow**:
  * Trigger: Daily at 9 AM (Cron Schedule).
  * Fetch stock data via the agent.
  * Use LLM to format insights and send via email.

#### **Knowledge Base Agent Example**

* **Name**: "Legal Document Analyzer"
* **Use Case**:
  * Summarize and analyze uploaded legal documents.
* **Workflow**:
  * Upload PDFs or Word files to the agent.
  * Query the agent for summaries or specific clauses.

#### **IoT (MQTT) Agent Example**

* **Name**: "Smart Light Controller"
* **Use Case**:
  * Manage smart lights in a home automation setup.
* **Workflow**:
  * Trigger: Based on sunset time (API or Cron).
  * Publish a "turn on lights" command to MQTT broker.
  * Confirm via a status update.

***

### **FAQs**

#### **1. Can I combine multiple agents in one workflow?**

Yes, agents can be combined using the **Agents Flow Builder** to create complex workflows.

#### **2. How secure is the data uploaded to knowledge base agents?**

All uploaded data is encrypted, and sensitive data can be masked or restricted using privacy policies.

#### **3. Can I modify an agent after deployment?**

Yes, agents can be unpublished, modified, and redeployed as needed.

#### **4. How do I integrate agents with external applications?**

Use the agent's unique **Agent ID** for API-based integrations or link it in workflows.
