Make Recommendations
To make recommendations, you must provide PROJECT_ID (from step 2), MODEL_KEY (make sure that the model is compatible with your entity catalog), and NUM_RESULTS (number of recommendations to return).
Request Parameters
In the request body, you must provide:
template: The prompt template that instructs our models to suggest next product or other recommendation tasks. The template should share keys defined in context.context: The user's context data (e.g., previous purchases, budget, etc.). You can keep the same context (aka data pipeline) and modify the template to fit your other use cases (say similar products that tailor to your end-user's preferences). context should be a dictionary where keys are the variables in your template and values are the corresponding data.
API Endpoint
curl -X POST "https://api.trydodo.xyz/api/recommend?project_id=${PROJECT_ID}&model_key=${MODEL_KEY}&num_results=${NUM_RESULTS}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"context": {
"previous_purchases": ["iPhone 16 512Gb", "Rich Dad Poor Dad book"]
},
"template": "Recommend next product to customer. Previous purchases: {previous_purchases}, Budget less than $100"
}'
Response Format
Response:
{
"status_code": 200, # successful recommendations
"decision_id": "decision_id", # unique identifier for this recommendation
"results": ["8","4","1","3","5","6","9","7","2","10"]
}
Data Pipeline in Production
In production, context is the output of your data pipeline. The data pipeline can be as simple as:
- SQL queries to aggregate data (no need to sort by timestamp) at backend
- Shopping history temporarily stored in the app with calls from your frontend
- For larger scale, we're working day and night on more advanced solutions
Context Data Examples
The more detailed the context and template are, the better the recommendations will be. For example, context can include:
[
{
"product_name": "iPhone 16 512Gb",
"price": 999,
"category": "electronics"
},
{
"product_name": "Rich Dad Poor Dad book",
"price": 10,
"category": "books"
}
]
Template Customization
You may modify template and context to fit your specific use case. Check out our industry templates for more examples.
Template Examples
Basic Product Recommendation
{
"template": "Recommend next product to customer. Previous purchases: {previous_purchases}, Budget less than $100",
"context": {
"previous_purchases": ["iPhone 16 512Gb", "Rich Dad Poor Dad book"]
}
}
Complementary Product Recommendation
{
"template": "Find something to complement my recent purchases in the same category. My recent purchases: {shopping_history}. Age: {age}, Gender: {gender}, Location: {location}",
"context": {
"age": 28,
"gender": "male",
"location": "Dallas",
"shopping_history": ["winter coat", "thermal shirt", "wool socks", "gloves", "scarf"]
}
}
Health-focused Recommendation
{
"template": "Focus on recent purchases to capture recent shopping trend. Please recommend something for me to overcome recent flu. Age: {age}, Gender: {gender}, Location: {location}, Recent purchases: {shopping_history}",
"context": {
"age": 28,
"gender": "male",
"location": "Dallas",
"shopping_history": ["winter coat", "thermal shirt", "wool socks", "gloves", "scarf"]
}
}
Best Practices
- Be Specific in Templates: Clear instructions lead to better recommendations
- Provide Rich Context: More detailed user data improves accuracy
- Test Different Templates: Experiment with various prompt styles
- Use Relevant Variables: Ensure template variables match context keys
- Consider User Intent: Align templates with user goals and needs
Next Steps
After getting recommendations:
- Track Feedback: Use our feedback SDKs to track user interactions
- Analyze Performance: Monitor recommendation effectiveness with analytics
- Optimize Templates: Refine prompts based on performance data
- Scale Integration: Implement recommendations in your production workflow