Analyze Sentiment
Analyze the sentiment and emotional tone of text.
Classifies the sentiment of text with the LLM as positive, negative, neutral or mixed, optionally with emotion scores or per-aspect sentiment, and routes to the port of that label.
Detect whether text is positive, negative, neutral, or mixed. Optionally break down into specific emotions or analyze sentiment per aspect/topic.
Operations:
- Overall: Single sentiment classification with valence score (-1 to 1) and confidence.
- Emotions: Detect specific emotions (joy, anger, sadness, fear, surprise, disgust, trust) with intensity scores.
- Aspect-Based: Extract topics/aspects mentioned in text and score sentiment for each independently.
How it works
- Resolves the node config: expressions in config keys are evaluated against the run; the incoming item is used as-is.
- Merges the incoming item with the resolved config (config keys win) and reads the inputs from the result.
- Requires
text. Picks the prompt foranalysis_mode(defaultoverall):overall,emotions(eight emotion scores and a dominant emotion) oraspect_based(per-aspect sentiment, focused onaspectswhen given). - Calls the LLM through the backend with the
llm_provider_idrecord.invocation_mode: "sync"(default) waits for the full answer;"stream"reads it over SSE and joins the chunks. - Parses the JSON answer (temperature 0);
sentimentmust be a string. Missing numbers become 0 and missing objectsnull. - Lower-cases the label and routes to
positive,negative,neutralormixed; any other label routes toneutralwhiledata.sentimentkeeps the original value.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-sentiment",
"label": "Detect sentiment",
"operator_slug": "ai.sentiment",
"operator_version": "1.0.0",
"config": {
"llm_provider_id": "<llm_provider_id>",
"analysis_mode": "overall",
"language": "en"
}
}{
"ok": true,
"port": "negative",
"data": {
"sentiment": "negative",
"valence": -0.7,
"confidence": 0.9,
"emotions": null,
"dominant_emotion": null,
"aspects": null,
"reasoning": "The customer complains about a late delivery."
}
}Configuration
-
llm_provider_idstring Optional -
The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.
-
invocation_modestring Optional -
Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.
-
timeout_msinteger Optional -
Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.
-
analysis_modestring Required -
Type of sentiment analysis to perform.
-
languagestring Optional -
aspectsarray<string> Optional -
Optional: specific aspects to analyze. Leave empty for auto-detection.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
llm_provider_id - Required at runtime although the schema does not mark it as required. It is the id of an LLM provider record; the backend resolves endpoint, deployment and credentials from it.
-
analysis_mode - Use one of the three listed values. An unknown value is not rejected: the model receives the word “undefined” as its system prompt.
-
language - Adds a reply-language line when it is not
en; labels stay in English. -
timeout_ms timeout_msonly takes effect instreammode, as the idle time allowed between chunks (default 600000). Insyncmode it is logged but the backend request has no timeout.
Output ports
positive default The label is positive. Same shape as the example.
{
"sentiment": "positive",
"valence": 0.8,
"confidence": 0.9,
"emotions": null,
"dominant_emotion": null,
"aspects": null,
"reasoning": "The customer thanks the team."
}negative The label is negative.
{
"sentiment": "negative",
"valence": -0.7,
"confidence": 0.9,
"emotions": null,
"dominant_emotion": null,
"aspects": null,
"reasoning": "The customer complains about a late delivery."
}neutral The label is neutral or not one of the four known labels.
{
"sentiment": "neutral",
"valence": 0,
"confidence": 0.9,
"emotions": null,
"dominant_emotion": null,
"aspects": null,
"reasoning": "A factual question about opening hours."
}mixed The label is mixed. In aspect_based mode aspects is filled.
{
"sentiment": "mixed",
"valence": 0.1,
"confidence": 0.85,
"emotions": null,
"dominant_emotion": null,
"aspects": [
{
"aspect": "food",
"sentiment": "positive",
"valence": 0.8,
"reasoning": "Praises the dishes."
},
{
"aspect": "service",
"sentiment": "negative",
"valence": -0.6,
"reasoning": "Long wait."
}
],
"reasoning": "Good food but slow service."
}error Validation, the LLM call or parsing failed. data is { error } (plus response when the backend returned a body).
{
"error": "Model did not return valid sentiment analysis output."
}In expressions
What a later node can read from this node's output with $("Analyze Sentiment").item.json.<path> (write your node's label instead of Analyze Sentiment). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through positive, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Analyze Sentiment").item.json.sentimentOverall sentiment label. | ||
$("Analyze Sentiment").item.json.valenceSentiment score from -1 (negative) to 1 (positive). | ||
$("Analyze Sentiment").item.json.confidenceConfidence score 0-1. | ||
$("Analyze Sentiment").item.json.emotionsEmotion breakdown (emotions mode). | ||
$("Analyze Sentiment").item.json.aspectsPer-aspect sentiment (aspect_based mode). | ||
$("Analyze Sentiment").item.json.reasoningBrief explanation. | ||
$("Analyze Sentiment").item.json.dominant_emotion | — |
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
Missing input text for sentiment analysis. | error | Neither text nor input is present. |
Model did not return valid sentiment analysis output. | error | The answer had no JSON object with a sentiment string. |
[AiSentiment] Missing 'llm_provider_id' in node config (LlmProviderModel.id, e.g. 'wf-llm-provider-*'). … | error | The node has no llm_provider_id. Pick an LLM provider in the node config; the legacy model_id key is not accepted. |
LLM Invocation Error: <backend message> | error | The backend rejected the call (unknown or inactive provider record, provider error, credentials). Check the provider record. |
LLM Invocation Error: empty response from backend (<reason>). | error | The backend could not be reached or returned nothing in sync mode. |
RemoteApiService.stream: idle timeout after <timeout_ms>ms | error | In stream mode no chunk arrived within timeout_ms. |
Input contract
-
textstring Required -
Text to analyze.
Output contract
-
sentimentstring Optional -
Overall sentiment label.
-
valencenumber Optional -
Sentiment score from -1 (negative) to 1 (positive).
-
confidencenumber Optional -
Confidence score 0-1.
-
emotionsobject Optional -
Emotion breakdown (emotions mode).
-
aspectsarray Optional -
Per-aspect sentiment (aspect_based mode).
-
reasoningstring Optional -
Brief explanation.
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "ai.sentiment",
"name": "Analyze Sentiment",
"category": "ai",
"version": "1.0.0",
"description": "Analyze the sentiment and emotional tone of text.\n\n Detect whether text is positive, negative, neutral, or mixed. Optionally break down into specific emotions or analyze sentiment per aspect/topic.\n\n **Operations:**\n - **Overall:** Single sentiment classification with valence score (-1 to 1) and confidence.\n - **Emotions:** Detect specific emotions (joy, anger, sadness, fear, surprise, disgust, trust) with intensity scores.\n - **Aspect-Based:** Extract topics/aspects mentioned in text and score sentiment for each independently.",
"capabilities": [
"nlp",
"sentiment",
"emotions",
"analysis"
],
"config_schema": {
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"analysis_mode": {
"type": "string",
"title": "Analysis Mode",
"enum": [
"overall",
"emotions",
"aspect_based"
],
"default": "overall",
"description": "Type of sentiment analysis to perform."
},
"language": {
"type": "string",
"title": "Language",
"default": "en"
},
"aspects": {
"type": "array",
"title": "Aspects",
"description": "Optional: specific aspects to analyze. Leave empty for auto-detection.",
"items": {
"type": "string"
},
"displayOptions": {
"show": {
"analysis_mode": [
"aspect_based"
]
}
}
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"analysis_mode"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Text to analyze."
}
},
"required": [
"text"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"sentiment": {
"type": "string",
"description": "Overall sentiment label."
},
"valence": {
"type": "number",
"description": "Sentiment score from -1 (negative) to 1 (positive)."
},
"confidence": {
"type": "number",
"description": "Confidence score 0-1."
},
"emotions": {
"type": "object",
"description": "Emotion breakdown (emotions mode)."
},
"aspects": {
"type": "array",
"description": "Per-aspect sentiment (aspect_based mode)."
},
"reasoning": {
"type": "string",
"description": "Brief explanation."
}
}
},
"ports": [
{
"port_id": "positive",
"label": "Positive",
"description": "Sentiment is positive.",
"is_default": true,
"supports_condition": true
},
{
"port_id": "negative",
"label": "Negative",
"description": "Sentiment is negative.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "neutral",
"label": "Neutral",
"description": "Sentiment is neutral.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "mixed",
"label": "Mixed",
"description": "Sentiment is mixed.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Analysis failed.",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"tags": [
"ai",
"nlp",
"sentiment",
"emotions"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"analysis_mode": {
"type": "string",
"title": "Analysis Mode",
"enum": [
"overall",
"emotions",
"aspect_based"
],
"default": "overall",
"description": "Type of sentiment analysis to perform."
},
"language": {
"type": "string",
"title": "Language",
"default": "en"
},
"aspects": {
"type": "array",
"title": "Aspects",
"description": "Optional: specific aspects to analyze. Leave empty for auto-detection.",
"items": {
"type": "string"
},
"displayOptions": {
"show": {
"analysis_mode": [
"aspect_based"
]
}
}
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"analysis_mode"
]
}{
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Text to analyze."
}
},
"required": [
"text"
]
}{
"type": "object",
"properties": {
"sentiment": {
"type": "string",
"description": "Overall sentiment label."
},
"valence": {
"type": "number",
"description": "Sentiment score from -1 (negative) to 1 (positive)."
},
"confidence": {
"type": "number",
"description": "Confidence score 0-1."
},
"emotions": {
"type": "object",
"description": "Emotion breakdown (emotions mode)."
},
"aspects": {
"type": "array",
"description": "Per-aspect sentiment (aspect_based mode)."
},
"reasoning": {
"type": "string",
"description": "Brief explanation."
}
}
}[
{
"port_id": "positive",
"label": "Positive",
"description": "Sentiment is positive.",
"is_default": true,
"supports_condition": true
},
{
"port_id": "negative",
"label": "Negative",
"description": "Sentiment is negative.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "neutral",
"label": "Neutral",
"description": "Sentiment is neutral.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "mixed",
"label": "Mixed",
"description": "Sentiment is mixed.",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Analysis failed.",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
nlpsentimentemotionsanalysis- Tags
ainlpsentimentemotions
Notes and limits
- When
textis missing, the code falls back toinput, which at runtime is the whole incoming item (an object), not a string. Always providetext. - The model answer is parsed as JSON after removing Markdown code fences; if that fails, the text between the first
{and the last}is parsed. - Input fields are read from the incoming item (
$json). A key with the same name in the node config, which may be an expression, takes precedence over the input. - The worker also returns the provider response as
rawoutsidedata; the engine does not keep it. - On success the worker returns
portanddatawithout anokfield; the engine routes onportonly. timeout_msonly takes effect instreammode, as the idle time allowed between chunks (default 600000). Insyncmode it is logged but the backend request has no timeout.- In
streammode the temperature this node sets is not forwarded to the provider, andrawisnull. - The engine does not apply
execution.retryOnFail,maxTries,waitBetweenTriesorcontinueOnFailto this node. Handle failures by wiring theerrorport.
Reviewed against the orchestrator code · 31e874b · 2026-11-26