Topic Initialization
Respectify assesses a comment in the context of what it is replying to or is likely about. There is an implicit assumption that all comments are about something, and that is usually an article, blog post, or similar. It doesn't have to be online: you can just give Respectify some text.
You always need to initialize a topic so that when evaluating a comment, Respectify knows the 'something' that the conversation is about.
Reference
See the Topic Initialization API Reference for method signatures and parameters.
Response: InitTopicResponse
By Example
From Text
Initialize with plain text or Markdown content. Use this when you already have the content (e.g., when integrating into a blog engine, it's more efficient to pass the Markdown or text directly rather than requiring Respectify to fetch it from a URL):
- Python
- PHP
- REST API
- Blocking Client
- Async Client
result = client.init_topic_from_text(
"This article discusses the benefits of type hints in Python. "
"Type hints improve code readability and catch errors early..."
)
article_id = result.article_id
# Store this UUID for future comment analysis
result = await client.init_topic_from_text(
"This article discusses the benefits of type hints in Python. "
"Type hints improve code readability and catch errors early..."
)
article_id = result.article_id
# Store this UUID for future comment analysis
$client->initTopicFromText(
"This article discusses the benefits of type hints in Python. " .
"Type hints improve code readability and catch errors early..."
)->then(function ($articleId) {
echo "Article ID: $articleId\n";
// Store this UUID for future comment analysis
});
$client->run();
curl -X POST https://app.respectify.ai/v0.2/inittopic \
-H "X-User-Email: your@email.com" \
-H "X-API-Key: your-api-key" \
-d "text=This article discusses the benefits of type hints in Python. Type hints improve code readability and catch errors early..."
Response:
{
"article_id": "550e8400-e29b-41d4-a716-446655440000"
}
From URL
Respectify can fetch and read the contents of a webpage or document at a URL. Point it at a blog post, PDF, or other online content to use as topic context:
- Python
- PHP
- REST API
- Blocking Client
- Async Client
result = client.init_topic_from_url(
"https://your-blog.com/articles/python-type-hints"
)
article_id = result.article_id
result = await client.init_topic_from_url(
"https://your-blog.com/articles/python-type-hints"
)
article_id = result.article_id
$client->initTopicFromUrl("https://your-blog.com/articles/python-type-hints")
->then(function ($articleId) {
// Store $articleId
});
$client->run();
curl -X POST https://app.respectify.ai/v0.2/inittopic \
-H "X-User-Email: your@email.com" \
-H "X-API-Key: your-api-key" \
-d "url=https://your-blog.com/articles/python-type-hints"
Response:
{
"article_id": "550e8400-e29b-41d4-a716-446655440000"
}
The URL can point to an HTML page, Markdown file, PDF document, or plain text file. If the URL points to an unsupported format, the API raises an UnsupportedMediaTypeError (HTTP 415) describing the content type that was found.
Best Practices
- Store the article ID: Save the UUID in your database.
- Retain and reuse the ID: Don't re-initialize the same content unnecessarily. Each initialization is an API call, so retain the article ID and reuse it for every comment on that page or topic.
- Update when content changes: Re-initialize if the article is substantially edited.
- Use descriptive content: More context leads to better analysis.
Next Steps
Once you have an article ID:
- Evaluate Comments: Full quality analysis
- Check Relevance: On-topic verification
- Check Dogwhistles: Detect coded language
- Check Spam: Filter spam
- Megacall: Batch analysis of multiple types in one request