DEV Community

roberto degani
roberto degani

Posted on

Build a Real-Time Sentiment Analysis Dashboard with AI — Complete Tutorial

Every product team needs to understand how customers feel about their product. But manually reading through hundreds of reviews is painful. In this tutorial, I'll show you how to build a real-time sentiment analysis dashboard using the AI Text Analyzer API.

What We're Building

A dashboard that:

  • Analyzes customer reviews in real-time
  • Detects sentiment (positive, negative, neutral)
  • Extracts key themes and emotions
  • Supports 50+ languages automatically
  • Provides actionable insights

Prerequisites

  • Node.js 14+ or Python 3.7+
  • A RapidAPI account (free tier works)
  • Basic knowledge of REST APIs

Step 1: Get Your API Key

Head to the AI Text Analyzer API on RapidAPI. Subscribe to the free tier to get your API key.

Step 2: Analyze a Single Review (Node.js)

const axios = require('axios');

const API_KEY = 'YOUR_RAPIDAPI_KEY';
const API_HOST = 'ai-text-analyzer.p.rapidapi.com';

async function analyzeSentiment(text) {
  const response = await axios.post(
    `https://${API_HOST}/api/analyze`,
    { text, analyses: ['sentiment', 'emotion', 'keywords'] },
    {
      headers: {
        'x-rapidapi-key': API_KEY,
        'x-rapidapi-host': API_HOST,
        'Content-Type': 'application/json'
      }
    }
  );
  return response.data;
}

// Example usage
const review = "This product is amazing! The UI is intuitive and the performance is outstanding.";
analyzeSentiment(review).then(result => {
  console.log('Sentiment:', result.sentiment);
  console.log('Score:', result.sentiment_score);
  console.log('Emotions:', result.emotions);
  console.log('Keywords:', result.keywords);
});
Enter fullscreen mode Exit fullscreen mode

Step 3: Batch Processing Reviews

async function analyzeReviews(reviews) {
  const results = [];

  for (const review of reviews) {
    const analysis = await analyzeSentiment(review.text);
    results.push({
      original: review.text,
      sentiment: analysis.sentiment,
      score: analysis.sentiment_score,
      emotions: analysis.emotions,
      keywords: analysis.keywords
    });

    // Rate limiting - be respectful
    await new Promise(r => setTimeout(r, 500));
  }

  return results;
}

// Sample reviews
const reviews = [
  { text: "Love this product! Best purchase I've made this year." },
  { text: "The app crashes frequently. Very frustrating experience." },
  { text: "Decent quality for the price. Nothing special." },
  { text: "Customer support was incredibly helpful and resolved my issue quickly." },
  { text: "Shipping took forever and the packaging was damaged." }
];

analyzeReviews(reviews).then(results => {
  // Summary statistics
  const positive = results.filter(r => r.sentiment === 'positive').length;
  const negative = results.filter(r => r.sentiment === 'negative').length;
  const neutral = results.filter(r => r.sentiment === 'neutral').length;

  console.log('\n=== SENTIMENT DASHBOARD ===');
  console.log(`Total Reviews: ${results.length}`);
  console.log(`Positive: ${positive} (${(positive/results.length*100).toFixed(1)}%)`);
  console.log(`Negative: ${negative} (${(negative/results.length*100).toFixed(1)}%)`);
  console.log(`Neutral: ${neutral} (${(neutral/results.length*100).toFixed(1)}%)`);

  // Top keywords across all reviews
  const allKeywords = results.flatMap(r => r.keywords || []);
  console.log('\nTop Keywords:', [...new Set(allKeywords)].slice(0, 10).join(', '));
});
Enter fullscreen mode Exit fullscreen mode

Step 4: Python Version

import requests
import json

API_KEY = 'YOUR_RAPIDAPI_KEY'
API_HOST = 'ai-text-analyzer.p.rapidapi.com'

def analyze_sentiment(text):
    headers = {
        'x-rapidapi-key': API_KEY,
        'x-rapidapi-host': API_HOST,
        'Content-Type': 'application/json'
    }

    payload = {
        'text': text,
        'analyses': ['sentiment', 'emotion', 'keywords']
    }

    response = requests.post(
        f'https://{API_HOST}/api/analyze',
        headers=headers,
        json=payload,
        timeout=30
    )
    response.raise_for_status()
    return response.json()

# Analyze multiple reviews
reviews = [
    "This is the best tool I've ever used for project management!",
    "Terrible customer service. Never buying again.",
    "It works fine. Does what it says.",
    "The new update broke everything. Very disappointed.",
    "Exceeded my expectations. Highly recommended!"
]

results = []
for review in reviews:
    analysis = analyze_sentiment(review)
    results.append({
        'text': review,
        'sentiment': analysis.get('sentiment'),
        'score': analysis.get('sentiment_score')
    })

# Print dashboard
positive = sum(1 for r in results if r['sentiment'] == 'positive')
negative = sum(1 for r in results if r['sentiment'] == 'negative')
print(f"Positive: {positive}/{len(results)}")
print(f"Negative: {negative}/{len(results)}")
Enter fullscreen mode Exit fullscreen mode

Use Cases

Use Case How It Helps
Product Reviews Identify common complaints and praise points
Social Media Monitoring Track brand sentiment across platforms
Customer Support Prioritize angry customers automatically
Market Research Compare sentiment across competitors
Content Analysis Understand audience reactions to content

Multilingual Support

One of the best features: the API automatically detects and analyzes text in 50+ languages. No extra configuration needed:

// Works in any language!
await analyzeSentiment("Este producto es increible!"); // Spanish
await analyzeSentiment("Dieses Produkt ist fantastisch!"); // German
await analyzeSentiment("Ce produit est incroyable!"); // French
Enter fullscreen mode Exit fullscreen mode

Pro Tips

  1. Batch your requests — Process reviews in batches of 10-50 for efficiency
  2. Cache results — Store analysis results to avoid duplicate API calls
  3. Set up alerts — Trigger notifications when sentiment drops below a threshold
  4. Track over time — Store daily sentiment scores to identify trends
  5. Combine with content generation — Use the AI Content Generator API to auto-draft responses to negative reviews

Conclusion

With the AI Text Analyzer API, building a sentiment analysis dashboard takes minutes, not weeks. The API handles the complex NLP work so you can focus on acting on the insights.

Get started:

Happy analyzing!

Top comments (0)