Skip to main content

"What to Watch Next?" Carousels

For any video streaming service, content platform, or media app, keeping viewers engaged after they finish a video is paramount. The "What to Watch Next?" recommendation feature is a critical tool in this effort. Whether it appears at the end of a video, in a dedicated row, or as part of the core navigation, its goal is simple: suggest the perfect next piece of content to keep the viewing session going, often leveraging the context of what was just watched. A successful implementation increases watch time, reduces churn, promotes content discovery, and significantly enhances the user experience. But building one that truly resonates requires navigating a complex technical landscape.

Building "What to Watch Next?" with Shaped using similar_items

Let's adapt the previous tutorial concept, focusing now on the similar_items endpoint.

Goal: Recommend the most relevant next videos for a user after they finish watching a specific video.

1. Ensure Data is Connected: Same as before: Have datasets connected for video_views (with user_id, video_id, timestamp) and video_metadata (with video_id, title, genre, etc.).

2. Define Your Model (YAML): The model definition is largely the same, as the underlying model needs to learn user preferences and item relationships to power any recommendation endpoint.

watch_next_model.yaml
model:
name: watch_next_recommendations # Can be the same model powering multiple endpoints
connectors:
- type: Dataset
name: video_views
id: views
- type: Dataset
name: video_metadata
id: videos
fetch:
events: |
SELECT
user_id,
video_id AS item_id,
timestamp AS created_at,

-- Optional: Create a label based on engagement

CASE
WHEN watch_percentage >= 0.8 THEN 1.0
WHEN watch_percentage >= 0.5 THEN 0.5
ELSE 0.1
END as label
FROM views
WHERE watch_percentage > 0.05

items: |
SELECT
video_id AS item_id,
title,
genre,
series_id,
episode_number,
duration
FROM videos

3. Create the Model:

shaped create-model --file watch_next_model.yaml

4. Monitor Training: Wait for the model to reach the ACTIVE state. Note that the model will go through Fetching, Tuning, Training, Deploying and then finally Active.

shaped view-model --model-name watch_next_recommendations

5. Fetch "Watch Next" Suggestions using similar_items: Once ACTIVE, use the similar_items API endpoint. Provide the user_id and the item_id of the video the user just finished watching.

const { ShapedClient } = require('@shapedai/shaped');

const shapedClient = new ShapedClient({ apiKey: apiKey });
const similarItemsResponse = await shapedClient.similarItems({
modelName: 'watch_next_recommendations',
itemId: 'VIDEO_JUST_WATCHED',
userId: 'VIEWER_XYZ', // User context for personalization
limit: 10,
returnMetadata: true
});
console.log(`Successfully retrieved ${similarItemsResponse.metadata.length} similar items.`);

Response Structure (from similar_items):

{
"ids": ["video_next_ep", "video_related_A", "video_related_B", ...], // Personalized related video IDs
"scores": [0.97, 0.90, 0.86, ...], // Relevance/Similarity scores
"metadata": [ // Optional: if return_metadata=true
{"title": "Series Title S01E03", "genre": "Sci-Fi", ...},
{"title": "Another Sci-Fi Movie", "genre": "Sci-Fi", ...},
{"title": "Film by Same Director", "genre": "Action", ...},
...
]
}

Your application uses this ranked list (ids) to display the "What to Watch Next?" suggestions, now contextually relevant to the last video watched and personalized for the user.

Using Shaped's similar_items endpoint directly addresses the contextual nature of the "What to Watch Next?" problem, simplifying the implementation compared to building custom context handling into a generic ranking system.

Conclusion: Focus on Viewing Experience, Not Infrastructure

A compelling "What to Watch Next?" feature is essential for modern video platforms, but building it traditionally is a resource-intensive marathon requiring deep expertise. Shaped, particularly with its similar_items endpoint, provides a streamlined path.

By handling the complex data pipelines, model training, low-latency contextual serving, and MLOps, Shaped allows you to leverage your viewing data to create highly effective, personalized, and context-aware video recommendations with significantly less effort. Stop wrestling with infrastructure and start delighting your viewers with seamless content discovery.

Ready to build an engaging "What to Watch Next?" feature?

Request a demo of Shaped today to see it in action with your specific use case. Or, start exploring immediately with our free trial sandbox.