---
schema_version: "1"
id: d4dbeec79427219a338b76ceae9689b429fac25db805a1288b5e8dd82e07bdc9
title: AI_SENTIMENT
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/ai-func/ai-sentiment.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/ai-sentiment.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 571d173ea45fef27ca5e9e960846bf8f3ad952f26d5b0c82a71c7d8946f73643
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `AI_SENTIMENT`

**Applies to:** ✅ Data 360 SQL ❌ Tableau Hyper API

Performs sentiment analysis on text input and returns a sentiment label. This function uses a multilingual sentiment model to analyze customer feedback, support tickets, survey responses, and other unstructured text.

## Syntax

```sql
ai_sentiment(<input_text>)
```

## Arguments

### Required

- `input_text`: The [text](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md) to analyze for sentiment. The function processes empty input values normally. The text must be a non-NULL value.

## Returns

Returns a [text](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md) sentiment label. Sentiment labels are:

- `Positive`: Text expressing positive sentiment
- `Negative`: Text expressing negative sentiment
- `Neutral`: Text expressing neutral sentiment
- `Mixed`: Text containing conflicting positive and negative signals
- `Unknown`: Text with unclear or indeterminate sentiment

## Considerations

- **Input text length**: The function supports input text up to 512 tokens (approximately 400-500 words). For longer text such as full call transcripts or lengthy emails, split the content into shorter passages before analyzing.
- **Best for short text**: This function works best on short, intent-rich text such as support tickets, CRM notes, social media posts, and chat messages.
- **Performance**: Requests to the function time out after 30 seconds.
- **First execution**: When executing this function on a large number of rows for the first time, you can encounter timeout or capacity errors. Start with smaller row counts and gradually increase volume to avoid these issues.
- **Non-NULL values**: `input_text` must be a non-NULL value. Add `IS NOT NULL` to the `WHERE` clause in your SQL statement to avoid `NULL` value errors.
- **Multilingual support**: The underlying model supports multiple languages.

## Examples

### Using Table Data

Analyzes sentiment for multiple rows from a table.

```sql
SELECT
  "customerServiceFeedback__c",
  ai_sentiment("customerServiceFeedback__c") AS sentiment
FROM "AutomobileServiceFeedback__dll"
```

Returns the sentiment of the feedback for each row in the `AutomobileServiceFeedback__dll`.

### Filtering Results

Show only positive feedback in a table.

```sql
WITH AnalyzedFeedback AS (
  SELECT
    "customerServiceFeedback__c",
    ai_sentiment("customerServiceFeedback__c") AS sentiment
  FROM "AutomobileServiceFeedback__dll"
)
SELECT * FROM AnalyzedFeedback
WHERE sentiment = 'positive';
```

Returns all positive feedback.

## Related Documentation

- [Sentiment Analysis](https://help.salesforce.com/s/articleView?id=data.c360_a_ai_predictive_model_sentiment.htm&type=5): Learn about sentiment analysis models, use cases, and integration options.
- [AI Models in Data Cloud](https://help.salesforce.com/s/articleView?id=data.c360_a_ai_create_connect_activate_models.htm&type=5): Read an overview of AI model capabilities.
