RecommendationService
A service that provides an interface for developers to manage and display personalized content recommendations.
| Memory category | Instances |
|---|
Member index 7
Description
RecommendationService provides an interface for developers to manage and display personalized content recommendations. It supports creating, retrieving, updating, and deleting recommendation items, as well as generating lists of recommended content for users. Additionally, it includes functionality for logging user interactions, such as views and actions, to help refine and improve recommendation quality.
Note: RecommendationService is currently available for free, but its pricing
model might change in the future.
History 9
- 690 Add GetRecommendationItemAsync
- 683 Change Parameters of RegisterItemAsync from (registerRecommendationItemsRequest: Dictionary) to (player: Player, registerRecommendationItemsRequest: Dictionary)
- 678 Add UpdateItemAsync
- 678 Add RemoveItemAsync
- 678 Add RegisterItemAsync
- 678 Add LogImpressionEvent
- 678 Add LogActionEvent
- 678 Add GenerateItemListAsync
- 678 Add RecommendationService
Members 7
GenerateItemListAsync
| Parameters (1) | ||
|---|---|---|
| generateRecommendationItemListRequest | Dictionary | |
| Returns (1) | ||
| RecommendationPages | ||
This function returns a paginated list of recommended items based on a given request. The request can specify criteria such as configuration name, location, and page size to tailor the recommendations. It returns a RecommendationPages object that can be used to iterate through the list of items.
The ConfigName parameter determines how the recommendation engine ranks
and returns items. For example, you can have configurations that optimize
for views, likes, or purchases. For the ranking to be effective, you must
ensure that you are logging the corresponding user interactions using
LogImpressionEvent and
LogActionEvent.
Supported ConfigName are:
MaximizeTimespent: Optimizes recommendations to prioritize content that engages users for longer periods.MaximizeReactions: Optimizes recommendations to highlight content that generates the most user reactions, such as likes and favorites.MaximizeEngagement: Optimizes recommendations through a balanced approach that considers multiple engagement signals, including quality views and reactions. This config is designed to highlight content that performs well across different engagement areas.PlayerSpecific: Returns public items created by the player specified in the request and sorted by the most recent creation time. To use this config, you must pass theUserIdin theCustomContexts.RecentlyAdded: Returns items sorted by how recent they are, and displays the most recently added public content first.MaximizeJoins: (Coming soon) Optimizes recommendations to prioritize game joins. This config is currently only available for Roblox Moments.PlayerOwnedItems: Displays the user's own creations sorted by creation time. This config requires user authentication because it displays private items. This config is only available on the client.
This function can be called from both the server and the client.
When called from the server, you must pass the UserId in the
CustomContexts.
| Thread safety | Unsafe |
|---|
History 1
GetRecommendationItemAsync
| Parameters (1) | ||
|---|---|---|
| itemId | string | |
| Returns (1) | ||
| Dictionary | ||
This function returns a single recommendation item by its ItemId. This
is useful for getting the details of a specific item without having to
fetch a whole list.
This function can be called only from the server.
| Thread safety | Unsafe |
|---|
History 1
LogActionEvent
| Parameters (4) | Default | |
|---|---|---|
| actionType | RecommendationActionType | |
| itemId | string | |
| tracingId | string | |
| actionEventDetails | Dictionary | nil |
| Returns (1) | ||
| null | ||
This function logs a user action on a recommended item, such as a "like,"
"share," or "purchase." It requires the itemId of the item and a
tracingId from the GenerateItemListAsync response to link the action to
a specific recommendation context. Additional details about the action can
be provided in the actionEventDetails dictionary.
Logging actions is essential for recommendation configurations that rank items based on user engagement such as number of likes or purchases.
This function can only be called from the client.
Note: Only LogActionEvent calls in production actually log actions.
Calling this function in Studio doesn't have any effect; you can call it
as many times as you want when testing.
| Thread safety | Unsafe |
|---|
History 1
- 678 Add LogActionEvent
LogImpressionEvent
| Parameters (4) | Default | |
|---|---|---|
| impressionType | RecommendationImpressionType | |
| itemId | string | |
| tracingId | string | |
| impressionEventDetails | Dictionary | nil |
| Returns (1) | ||
| null | ||
This function logs an impression event, such as a user viewing a
recommended item. It requires the itemId and a tracingId to associate
the impression with the recommendation context. Details like view duration
and position can be passed in the impressionEventDetails dictionary to
provide more context for the recommendation engine.
Logging impressions, especially Duration, is critical for recommendation
configurations that rank items based on view time.
This function can only be called from the client.
Note: Only LogImpressionEvent calls in production actually log
impressions. Calling this function in Studio doesn't have any effect; you
can call it as many times as you want when testing.
| Thread safety | Unsafe |
|---|
History 1
RegisterItemAsync
| Parameters (2) | ||
|---|---|---|
| player | Player | |
| registerRecommendationItemsRequest | Dictionary | |
| Returns (1) | ||
| Dictionary | ||
This function registers a new item to be included in recommendations. It
requires a player object and a registerRecommendationItemsRequest
dictionary containing details about the item, such as its content type,
reference ID, and custom tags. It returns a dictionary with the ItemId
and the ReferenceId of the newly registered item.
The ItemId is a unique ID returned by the RecommendationService. All
functions in the RecommendationService use the ItemId as input and
output.
The ReferenceId is a developer-provided identifier for an item. To make
sure that this reference ID is unique, we recommend that you use a UUID.
You can use this reference ID as a key to store rendering-specific
metadata in a data store.
When you register an item, you should only provide information that is relevant for ranking and recommendations. All other data needed for rendering should be stored separately in, for example, a data store. This approach decouples the recommendation logic from the rendering process, and results in a system that is more modular and easier to maintain.
Attributes is a list of content attributes associated with the item.
Each attribute in the list can contain the following fields:
AssetId— The ID of an asset, such as an image or video.Text— A short text string, like a title.Description— A longer text description for the attribute.SeekStartTime/SeekEndTime— The start and end times for seeking within video content.TrimStartTime/TrimEndTime— The start and end times for trimming video content.
This function can only be called from the server.
| Thread safety | Unsafe |
|---|
History 2
- 683 Change Parameters of RegisterItemAsync from (registerRecommendationItemsRequest: Dictionary) to (player: Player, registerRecommendationItemsRequest: Dictionary)
- 678 Add RegisterItemAsync
RemoveItemAsync
| Parameters (1) | ||
|---|---|---|
| itemId | string | |
| Returns (1) | ||
| null | ||
This function removes an item from the recommendation system. It takes the
itemId of the item to be deleted as a parameter.
This function can be called from both the server and the client, with the following limitations:
- When called from the server, it can only remove items registered under
the same
universeId. - When called from the client, it can only remove items registered by the
current
player.
| Thread safety | Unsafe |
|---|
History 1
- 678 Add RemoveItemAsync
UpdateItemAsync
| Parameters (1) | ||
|---|---|---|
| updateRecommendationItemRequest | Dictionary | |
| Returns (1) | ||
| null | ||
This function updates the attributes of an existing recommendation item.
It takes an updateRecommendationItemRequest dictionary containing the
itemId and the fields to be updated. Any fields not included in the
request will remain unchanged.
Items with their
RecommendationItemVisibility set to
Private are not recommended to other users, but they can still be
returned when a user requests their own creations by using the
ConfigName of PlayerOwnedItems.
In Roblox Moments, moderated items are set to Private. While this
prevents other users from seeing them, the item creator can still see
these moderated items and check their moderation status in their My
Moments tab.
This function can only be called from the server.
| Thread safety | Unsafe |
|---|
History 1
- 678 Add UpdateItemAsync