Understanding the collective mood—or sentiment—of your community is crucial for fostering a healthy, engaged, and positive environment. Are users excited about a new feature? Frustrated by a bug? Is a discussion heating up and at risk of violating community guidelines? Manually reading every post to gauge this is impossible at scale.
This is where programmatic analysis becomes a superpower for community managers and developers. At forum.services.do, we've transformed complex AI tasks into simple API calls. Today, we're taking a deep dive into one of our most powerful features: the sentiment analysis function. This technical walkthrough will show you how to use our forum API to programmatically gauge community mood and react in real-time.
Before we jump into the code, let's quickly cover why sentiment analysis is so vital. It's about moving from reactive problem-solving to proactive community nurturing. With an effective sentiment analysis tool, you can:
Traditionally, implementing this would require deep knowledge of machine learning, data pipelines, and model training. With forum.services.do, it's just an API call.
Our platform is designed to treat community operations as software. Following this principle, we've exposed our AI-powered sentiment analysis through a simple, intuitive endpoint. Let's explore how you can use it with our TypeScript SDK.
The most basic use case is analyzing a raw string of text. This is perfect for quick tests or integrating with systems outside your forum.services.do instance, like support chat logs or social media mentions.
import { forum } from '@services/do';
const textToAnalyze = "I'm really struggling to get the authentication flow to work. The documentation seems unclear.";
const analysis = await forum.analytics.analyzeSentiment({
content: textToAnalyze
});
// The response gives you a clear, actionable result
console.log(analysis);
// Expected Output:
// {
// label: 'NEGATIVE',
// score: -0.82,
// keywords: ['struggling', 'unclear']
// }
The response is straightforward:
The real power comes from integrating this analysis directly with your community content. Instead of passing raw text, you can simply provide a threadId or postId. Our AI agent handles the rest, fetching the content and running the analysis.
This is incredibly useful for building automated workflows. For example, you can analyze the sentiment of every new thread as it's created.
import { forum } from '@services/do';
// Assume 't-xyz789' is the ID of a newly created thread
const threadId = 't-xyz789';
const threadSentiment = await forum.analytics.analyzeSentiment({
threadId: threadId
});
console.log(`Sentiment for thread ${threadId}: ${threadSentiment.label} (${threadSentiment.score})`);
if (threadSentiment.score < -0.7) {
// Trigger a notification for a human moderator to review
console.log('High negative sentiment detected. Flagging for review.');
}
Individual post analysis is great, but what about the bigger picture? Our API allows you to aggregate sentiment data across an entire forum or for a specific user over a period of time. This unlocks high-level strategic insights into your community's health.
Let's find out the overall sentiment of a specific forum over the last 30 days.
import { forum } from '@services/do';
const communityHealth = await forum.analytics.analyzeSentiment({
forumId: 'f-12345', // Your main product discussion forum
timeRange: '30d'
});
console.log(communityHealth);
// Expected Output:
// {
// forumId: 'f-12345',
// timeRange: '30d',
// averageScore: 0.15,
// distribution: {
// positive: 450,
// neutral: 800,
// negative: 150
// },
// trend: 'stable' // or 'improving', 'declining'
// }
This aggregated data is invaluable for reports, dashboards, and understanding the direct impact of your product launches and community initiatives.
Let's tie this all together in a real-world scenario. Imagine you want to automatically create a support ticket whenever a user expresses significant frustration about a bug.
You can set up a webhook that fires every time a new post is created. Your webhook endpoint would then execute the following logic:
This is the power of treating your community as software. You've just built an automated, intelligent agent that improves user engagement and reduces response times, all with a few API calls.
The voice of your community contains a wealth of information. With the forum.services.do sentiment analysis API function, you can finally unlock it at scale. Move beyond guesswork and start making data-driven decisions that foster growth, loyalty, and a thriving online space.
Ready to automate your community management? Explore our platform and see how a single API can redefine how you engage your users.