# Create your first AI Agent for sentiment analysis

Build a working AI-powered sentiment analysis API that classifies customer feedback as **positive**, **negative**, or **neutral**.

<figure><img src="https://3750561495-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaD6wuPRxnEQEsYpePq36%2Fuploads%2Fx8TWeuaQkV8fa1A0qit0%2FQS%20%231%20(English).gif?alt=media&#x26;token=1d28c4fa-616a-48fe-a76d-7d04bc5dfa84" alt=""><figcaption></figcaption></figure>

## Step-by-step

In this quickstart, you will create a simple API that analyzes text sentiment in four steps.

### 1. Get your LLM provider API Key

Before you begin, make sure you have the following:

* An API key from an LLM provider (for example, OpenAI, Anthropic, Google).
* The API key registered in Digibee as a **Secret Key** account.

If you don’t have this account yet, see the documentation to [create a Secret Key account](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/platform-administration/settings/accounts#secret-key).

### 2. Create the REST-triggered pipeline

Create a new pipeline and configure the [trigger](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/overview) as follows:

* **Type:** Select [REST](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/rest).
* **Methods:** Remove all methods and leave only POST.
* **Other settings:** Keep the default values.

To expose this pipeline as an API, you must configure an API key and deploy the pipeline. See the [documentation](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/rest) to learn how to expose a pipeline as an API.

### 3. Add the Agent Component

Add the [Agent Component](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/ai-tools/llm) to the pipeline right after the trigger and configure it with the settings below:

* **Model:** Select your preferred model (for example, **OpenAI - GPT-4o Mini**)
* **Account**: Click the gear icon next to the model and select the Secret Key account you registered on **step 1**.

Next, configure the Agent messages:

* **System Message:** Defines the AI’s role and behavior.

```
You are a sentiment analyzer. Classify text as positive, negative, or neutral.
```

* **User Message:** Prompt that will be analyzed by the AI.

```
{{ message.body.text }}
```

{% hint style="info" %}
ℹ️ The `{{ message.body.text }}` expression dynamically retrieves data from the request payload. When the API is called with `{"body": {"text": "some text"}}`, the Agent receives and processes this value. To learn more, see how [Double Braces expressions are used to dynamically reference data](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/double-braces/how-to-reference-data-using-double-braces).
{% endhint %}

### 4. Test the Agent

In the Agent Component configuration, use the **Test Panel**, located on the right side of the page, and enter the following input:

```json
{
  "body": {
    "text": "This product is amazing! Best purchase ever."
  }
}

```

Then, click **Play** to view the results.

Below is an example of an output returned by the Agent:

```json
{
  "body": {
    "text": "Positive"
  },
  "tokenUsage": {
    "inputTokenCount": 41,
    "outputTokenCount": 2,
    "totalTokenCount": 43
  }
}

```

## Result

Kudos! You now have a working AI-powered sentiment analysis API. As a next step, [learn how to structure your output](https://docs.digibee.com/documentation/resources/quickstarts/turn-ai-into-structured-output) to force the AI to return consistent and deterministic JSON responses.

## Related topics

* [**Turn AI responses into a structured JSON output**](https://docs.digibee.com/documentation/resources/quickstarts/turn-ai-into-structured-output): Transform unstructured answers into structured outputs
* [**Use an MCP Server tool to connect AI agents to external systems**](https://docs.digibee.com/documentation/resources/quickstarts/connect-agents-to-external-systems): Use tools to retrieve external data through the Deepwiki MCP Server.
* [**AI expense report validation system**](https://docs.digibee.com/documentation/resources/ai-practical-examples/expense-report-validation-with-ai)**:** Explore a real-world implementation in this How-to guide.
* [**Insurance claim analysis with AI**](https://docs.digibee.com/documentation/resources/ai-practical-examples/insurance-claim-analysis-with-ai)**:** Build a multi-agent system to help review insurance claims.
