Skip to content

Sentiment Analysis

Also called: Sentiment scoring · Emotion detection · Opinion mining

Definition
Scoring each customer message as positive, neutral or negative — and spotting frustration — so support teams can prioritise, escalate or follow up.

Exhibit A

Watch one conversation's sentiment swing

4 / 4
-1.00-0.500.000.501.000.60
  • Frustrated · hand off-1.00–-0.60
  • Negative · prioritise-0.60–-0.20
  • Neutral-0.20–0.20
  • Positive0.20–1.00
Reading 4 of 4Positive

"ok thanks 👍"

0.60

After an apology, a new delivery date and a coupon, the customer's tone recovers to positive.

An illustrative delayed-parcel chat, scored message by message from −1 to +1. Step through to see when the rolling score crosses the handoff threshold, and how it recovers once an agent steps in.

"ok thanks 👍": 0.60 — Positive zone. After an apology, a new delivery date and a coupon, the customer's tone recovers to positive.

What is sentiment analysis?

Sentiment analysis is the automated scoring of the emotional tone of text. In customer support it labels each inbound WhatsApp message — or the conversation as a whole — as positive, neutral or negative, usually with a score from −1 (very negative) to +1 (very positive), and sometimes with finer emotions such as frustration, anger or confusion. It is one layer of a natural language understanding (NLU) pipeline, alongside language identification, intent and entities.

Sentiment is an emotional signal, which makes it different from intent recognition. "I want to cancel my order" has a clear intent and neutral sentiment; "third time asking, where is my refund??" has the same refund intent and strongly negative sentiment. Routing decides who handles a case from the intent; sentiment decides how urgently, and whether a bot should keep going or step aside for a person.

Approaches range from word lists and rules, to trained classifiers, to prompting a large language model for a label and score. Accuracy depends on the traffic: Indian support chats mix Hindi and English in Latin script, use sarcasm ("great service, 6 days and still no parcel") and lean on emoji, all of which trip models trained on formal English. Sentiment also differs from CSAT, which customers report themselves after the conversation; sentiment is inferred during it, so it can trigger action while there is still time to fix the problem.

Key takeaways

  • Sentiment analysis scores how a customer feels — usually on a scale from −1 (negative) to +1 (positive) — from their messages.
  • It measures emotion, not purpose: intent recognition says what the customer wants, sentiment how they feel about it.
  • Act on the trend across a conversation, not on a single message, to avoid escalating on one blunt reply.
  • Code-mixed Hinglish, sarcasm and emoji are the main accuracy traps in Indian support traffic.
  • Use sentiment to reorder queues and trigger handoff, and check thresholds against CSAT before automating.

Why does sentiment analysis matter?

On a busy WhatsApp support line, the angriest customer is often the one waiting longest, because queues are sorted by arrival time. Sentiment analysis surfaces those conversations, triggers a human handoff before a bot loop makes things worse, and flags at-risk customers before they leave a one-star review or a low rating. Aggregated across thousands of chats, it also shows which product, courier or policy is generating frustration this week — feedback that rarely arrives any other way.

How does sentiment analysis work?

  1. Score every inbound message

    Run each customer message through the model as it arrives from the webhook — after language detection, so Hindi, Tamil or Hinglish text reaches a model that handles it — and store the label, score and model version with the message.

  2. Smooth across the conversation

    Keep a rolling score weighted towards recent messages. A single "ok" or a curt "no" should not swing the conversation; three increasingly negative messages should.

  3. Combine with intent and context

    Negative sentiment on a refund or delivery-delay intent, a repeat contact within 48 hours, or a high-value order is a stronger signal than any one factor on its own.

  4. Act on calibrated thresholds

    Below a threshold, move the conversation up the queue, switch from bot to agent, or show agent assist cues such as an apology template and the order timeline beside the chat.

  5. Check against outcomes

    Every few weeks, compare scores with CSAT responses, reopen rates and agents' conversation tagging, and adjust thresholds per language and per queue.

Example: A delayed parcel in Lucknow

A customer of a Lucknow fashion retailer messages "order kab aayega?" (neutral, −0.1). Two hours later: "6 din ho gaye, tracking bhi update nahi ho raha" (−0.45, negative). Then: "Worst experience. Refund chahiye abhi 😡" (−0.85). The rolling score crosses the team's −0.6 threshold, so the bot stops sending tracking links and hands the chat to a senior agent with a frustration flag. The agent apologises, shares the courier's new delivery date and a goodwill coupon; the customer's last message, "ok thanks, mil gaya link 👍", scores +0.6 and the case closes. The scores here are illustrative.

Common mistakes with sentiment analysis

  • Escalating on one message

    Short replies like "no" or "hmm" score negative out of context. Use a rolling score and require a sustained trend or a clear frustration signal before acting.

  • English-only models on Indian traffic

    A model trained on English reviews misreads "bahut bekaar service" or romanised Tamil. Test on a sample of your own code-mixed chats and route by detected language.

  • Treating sentiment as satisfaction

    A customer can be terse but satisfied, or polite and about to leave. Validate thresholds against ratings and repeat-contact data before letting them drive decisions.

  • Showing raw scores to agents

    A number like −0.47 invites argument. Show a simple flag — frustrated, at risk — with the reason, and keep raw scores for analytics.

Sentiment analysis in code

import json
PROMPT = """Classify the customer's sentiment in this WhatsApp support message.
The text may mix Hindi and English in Latin script. Read sarcasm by its real meaning.
Return JSON only: {"label": "positive|neutral|negative",
"score": <number from -1 to 1>, "frustrated": true|false}"""
def score_message(text: str) -> dict:
data = json.loads(llm.generate(system=PROMPT, user=text, json_mode=True))
data["score"] = max(-1.0, min(1.0, float(data["score"])))
return data
def on_inbound(conv, text: str) -> None:
s = score_message(text)
save_score(conv.id, s, model_version=MODEL_VERSION)
# Exponential moving average: recent messages count more.
conv.sentiment = 0.6 * s["score"] + 0.4 * conv.sentiment
if conv.sentiment <= -0.6 or (s["frustrated"] and conv.repeat_contact):
handoff(conv, reason="negative_sentiment", priority="high")

Score each message, keep a rolling average, and escalate only on a sustained trend or clear frustration on a repeat contact.

Best practices for sentiment analysis

  • Score after language detection, and keep separate thresholds per language.
  • Store the model version with each score so trends survive a model change.
  • Exclude the bot's and agents' own messages from customer sentiment.
  • Read a weekly sample of the most negative conversations — it is some of the fastest product feedback you will get.

Sentiment Analysis FAQs

What is the difference between sentiment analysis and intent recognition?+
Intent recognition identifies what the customer wants; sentiment analysis measures how they feel. The two combine well: a refund request with strongly negative sentiment deserves faster, human attention than the same request made calmly.
Can sentiment analysis handle Hinglish?+
Yes, if the model is built or tested for it. Many off-the-shelf models trained on English misread romanised Hindi, sarcasm and emoji, so evaluate on a sample of your own chats before relying on the scores.
Should a bot hand over to a human when sentiment turns negative?+
Usually yes, once the negativity is sustained rather than a single blunt message. A rolling score below a calibrated threshold, or explicit frustration on a repeat contact, is a common handoff trigger.
Is sentiment analysis the same as CSAT?+
No. CSAT is a rating the customer gives after the conversation; sentiment is inferred from their messages during it. Sentiment can prompt action in time, while CSAT tells you afterwards whether that action worked.

See InfiQ pricing

Try it on the official WhatsApp Business API

InfiQ is an official Meta Business Partner. Start a 7-day free trial — no card needed — and see this running on your own number.