Rating responses allow reviewers to provide numeric assessments on customizable scales, making them ideal for quality evaluations, performance reviews, and any scenario where you need quantifiable feedback that can be easily aggregated and analyzed.
Five-star quality assessment with descriptive labels:
Copy
request_data = { "processing_type": "deferred", "type": "markdown", "priority": "medium", "request_text": "Please rate the overall quality of this blog article:\n\n# '10 Essential Tips for Remote Work Productivity'\n\nWorking from home has become the new normal for millions of professionals worldwide. Whether you're a seasoned remote worker or just starting your work-from-home journey, these proven strategies will help you maintain peak productivity while enjoying the flexibility of remote work.\n\n## 1. Create a Dedicated Workspace\n\nDesignate a specific area in your home exclusively for work. This physical separation helps create mental boundaries between work and personal life...\n\n[Article continues with detailed tips and examples]", "response_type": "rating", "response_config": { "scale_min": 1, "scale_max": 5, "scale_step": 0.5, "required": True }, "default_response": 3, # Average rating if timeout "timeout_seconds": 86400, # 24 hours "platform": "api"}
# Customer satisfaction surveyrequest_data = { "processing_type": "deferred", "type": "markdown", "priority": "low", "request_text": "Based on this customer feedback, how likely would this customer be to recommend our service to others?\n\n**Customer Feedback:**\n'The onboarding process was smooth and the support team was incredibly helpful when I had questions. The product does exactly what I need it to do, and the pricing is fair. I've been using it for 6 months now and haven't had any major issues. The recent feature updates have made my workflow even more efficient. I'm quite satisfied overall.'\n\n**Usage Data:**\n- Customer for 6 months\n- Regular active user (4-5 times per week)\n- No support tickets for technical issues\n- Upgraded to premium plan after 3 months\n\nPlease rate on the NPS scale: 0-10 where 10 means extremely likely to recommend.", "response_type": "rating", "response_config": { "scale_min": 0, "scale_max": 10, "scale_step": 1, "required": True }, "default_response": 5, # Neutral default "timeout_seconds": 604800, # 7 days "platform": "api"}
Your application should validate received ratings:
Copy
def validate_rating_response(response_data, response_config): """Validate rating response against configuration""" if not isinstance(response_data, dict): return False, "Response must be an object" if "rating" not in response_data: return False, "Missing rating field" rating = response_data["rating"] # Validate numeric type if not isinstance(rating, (int, float)): return False, "Rating must be a number" # Check bounds scale_min = response_config["scale_min"] scale_max = response_config["scale_max"] if rating < scale_min or rating > scale_max: return False, f"Rating must be between {scale_min} and {scale_max}" # Check step alignment scale_step = response_config.get("scale_step", 1) if scale_step > 0: # Calculate if rating aligns with step steps_from_min = (rating - scale_min) / scale_step if not steps_from_min.is_integer(): return False, f"Rating must align with step increment of {scale_step}" # Check required if response_config.get("required", False) and rating is None: return False, "Rating is required" return True, "Valid"# Usage exampleis_valid, error_message = validate_rating_response( response_data={ "rating": 4.5, "rating_label": "Good - High quality" }, response_config={ "scale_min": 1, "scale_max": 5, "scale_step": 0.5, "required": True })