Rate Message
Rate an AI-generated message to provide feedback on the quality of the response. This helps improve the AI agent’s performance and track user satisfaction.
Endpoint
PUT https://api.nexusgpt.io/api/public/messages/{messageId}/rate
Authentication
Your Nexus API key for authentication
Path Parameters
The ID of the AI message to rate. This must be a message generated by the AI assistant, not a user message.
Request Body
The rating score from 1 to 5, where:
1 = Very Poor
2 = Poor
3 = Average
4 = Good
5 = Excellent
Optional text feedback providing additional context about the rating. Maximum length: 1000 characters.
{
"id" : "rating-550e8400-e29b-41d4" ,
"messageId" : "msg-123456789" ,
"score" : 5 ,
"feedback" : "Very helpful and accurate response!" ,
"createdAt" : "2024-01-15T10:30:00Z" ,
"updatedAt" : "2024-01-15T10:30:00Z"
}
Response Fields
Unique identifier for the rating
The ID of the message that was rated
The rating score provided (1-5)
The optional feedback text if provided
ISO 8601 timestamp of when the rating was created
ISO 8601 timestamp of when the rating was last updated
Example Usage
curl -X PUT https://api.nexusgpt.io/api/public/messages/msg-123456789/rate \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"score": 5,
"feedback": "Very helpful and accurate response!"
}'
Rating Guidelines
When to Rate Messages
After receiving a response : Rate immediately after receiving an AI response while the context is fresh
Quality feedback : Provide ratings that reflect the actual helpfulness of the response
Update ratings : You can update a previous rating by calling the endpoint again with the same message ID
Score Guidelines
Score Description When to Use
5 Excellent Perfect response, fully addresses the query, accurate and helpful 4 Good Mostly accurate and helpful with minor room for improvement 3 Average Adequate response but missing some details or partially helpful 2 Poor Response has significant issues or is mostly unhelpful 1 Very Poor Completely wrong, irrelevant, or unhelpful response
Common Patterns
1. Rate After Response Pattern
async function interactAndRate ( sessionId , userMessage ) {
// Send message
await sendMessage ( sessionId , userMessage );
// Get response
const messages = await getMessages ( sessionId , { limit: 2 , order: 'desc' });
const aiResponse = messages . find ( m => m . type === 'assistant' );
// Rate the response based on quality
if ( aiResponse ) {
const score = evaluateResponse ( aiResponse . content );
await rateMessage ( aiResponse . id , score );
}
}
2. Feedback Collection Pattern
async function collectUserFeedback ( messageId ) {
// Show rating UI to user
const { score , feedback } = await showRatingDialog ();
// Submit rating with optional feedback
try {
const rating = await rateMessage ( messageId , score , feedback );
console . log ( 'Thank you for your feedback!' );
return rating ;
} catch ( error ) {
console . error ( 'Failed to submit rating:' , error );
}
}
3. Batch Rating Pattern
async function rateMultipleMessages ( ratings ) {
const results = [];
for ( const { messageId , score , feedback } of ratings ) {
try {
const result = await rateMessage ( messageId , score , feedback );
results . push ({ success: true , rating: result });
} catch ( error ) {
results . push ({ success: false , messageId , error: error . message });
}
}
return results ;
}
Error Responses
401 Unauthorized
404 Not Found
400 Bad Request - Invalid Score
400 Bad Request - User Message
403 Forbidden
429 Too Many Requests
{
"statusCode" : 401 ,
"message" : "Invalid API key" ,
"error" : "Unauthorized"
}
Best Practices
Provide honest and accurate ratings
Include specific feedback when possible
Rate based on the actual helpfulness of the response
Consider the context of the conversation
Keep feedback constructive and specific
Mention what was good or what could be improved
Avoid personal information in feedback
Use clear and concise language
Store message IDs for later rating
Implement rating UI in your application
Handle rating errors gracefully
Consider implementing a rating reminder system
Track rating patterns over time
Monitor average scores by conversation type
Use feedback to identify improvement areas
Correlate ratings with user engagement
Limitations
Message Type : Only AI-generated messages can be rated (not user messages)
Score Range : Score must be an integer between 1 and 5
Feedback Length : Maximum 1000 characters for feedback text
Update Behavior : Rating the same message again will update the existing rating
Integration Scope : You can only rate messages from your own integration