> ## Documentation Index
> Fetch the complete documentation index at: https://docs.release0.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to integrate your Agent with Dify.AI

> Learn how to integrate Dify.AI assistant into your Agent Dialog for seamless chatbot interactions.

The **Dify.AI** element lets you seamlessly integrate your **Dify.AI assistant** into your **Agent Dialog**, enabling dynamic and intelligent conversations.

First you need to create an account on [Dify.AI](https://www.dify.ai/) and set up your AI assistant.
Your Dify.AI assistant consists of an app and a knowledge base.

## Prerequisites

1. **Dify.AI Account**: Sign up for a free account on [Dify.AI](https://www.dify.ai/).
2. **Create an App**: Set up your AI assistant by creating an [app](https://cloud.dify.ai/apps) in Dify.AI.
3. **Knowledge Base**: Populate your app with relevant data by creating a [knowledge base](https://cloud.dify.ai/datasets).
4. **Link Knowledge Base to App**: Ensure your knowledge base is linked to your app for optimal performance.
5. **API Key**: Obtain your app API key from the Dify.AI dashboard, click on the app you created, and navigate to the **left side menu**, then click on **API Keys** Located on the top right corner and then click on **Create new Secret Key** to generate and copy your API key.
6. **Knowledge Base Key**: Obtain your knowledge base key from the Dify.AI dashboard, click on the knowledge tab, then on the top left corner click on API ACCESS. Then click on **API Keys** Located on the top right corner and then click on **Create new Secret Key** to generate and copy your Knowledge API key.

> **Note**: App API Key satrts with `app-` and Knowledge Base Key starts with `dataset-`.

## Configure your Dify.AI element

1. **Add new Dify.AI element**: Select the **Dify.AI** element from the list of available elements.
2. **Add new Dify.AI Account**: Click on **Add new account** to configure your Dify.AI account.
3. **Enter Account Details**: Provide the following details:
   * **Account Name**: A name to identify your Dify.AI account.
   * **App API Key**: The API key you obtained from your Dify.AI app.
   * **Knowledge Base Key**: The API key you obtained from your Dify.AI knowledge base.
   * **Create Account**: Click on the **Create Account** button to save your Dify.AI account configuration.
4. **Select your Dify.AI Account**: Choose the Dify.AI account you just created from the dropdown menu.
5. **Save your element**: Click on the **Save** button to save your Dify.AI element configuration.

## Using the Dify.AI element in your Agent Dialog

Once your Dify.AI element is configured, you can use it in your **Agent Dialog** to send messages to your Dify.AI assistant.
This action sends a **user message** to your agent. The response can be saved to a variable and displayed in your **Agent Dialog**.

### Required Parameters

1. **Query**:\
   The **user message** you want to send to your agent.

2. **Conversation ID**:\
   The unique identifier for the conversation you want to associate with this message.
   * If no Conversation ID is provided, a new conversation will be automatically created.
   * This variable will update dynamically if a new conversation is initiated.

3. **Response Variable**:
   The variable where the response from your Dify.AI assistant will be stored.
   * You can create a new variable or select an existing one to store the response.
