

**End of support notice:** On October 30, 2026, AWS will end support for Amazon Pinpoint. After October 30, 2026, you will no longer be able to access the Amazon Pinpoint console or Amazon Pinpoint resources (endpoints, segments, campaigns, journeys, and analytics). For more information, see [Amazon Pinpoint end of support](https://docs.aws.amazon.com/console/pinpoint/migration-guide). **Note:** APIs related to SMS, voice, mobile push, OTP, and phone number validate are not impacted by this change and are supported by AWS End User Messaging.

# Machine learning models in Amazon Pinpoint
<a name="ml-models"></a>

A *machine learning (ML) model* is a mathematical representation of a real-world problem. An ML model finds patterns in data and generates predictions based on the patterns that it finds. These predictions typically improve over time, as an ML model receives more data and people retrain or tune the model to refine and optimize the model's analysis of data.

In Amazon Pinpoint, you can connect to a certain type of ML model, referred to as a *recommender model*, to predict which items a user will interact with and to send those items to message recipients as personalized recommendations. A *recommender model* is an ML model that's designed to answer the question, "What will a user like or be interested in?" It predicts what a particular user will prefer from a given set of products or items, and it provides that information as a set of recommendations for the user. By using recommender models with Amazon Pinpoint, you can send personalized recommendations to message recipients based on each recipient's attributes and behavior.

To use a recommender model with Amazon Pinpoint, start by working with your data science team to create and deploy the model as an Amazon Personalize campaign. Next, configure Amazon Pinpoint to use recommendation data from the Amazon Personalize campaign. You do this by setting up a connection between Amazon Pinpoint and the Amazon Personalize campaign. When you set up the connection, you specify how you want to retrieve and use data from the Amazon Personalize campaign.

After you set up the connection to the Amazon Personalize campaign, you can start adding recommendations to messages. To do this, create a message template. In the template, add message variables for the recommendations that you want to use. You can add these variables to the following types of templates:
+ Email templates, for email messages that you send from campaigns or journeys.
+ Push notification templates, for push notifications that you send from campaigns.
+ SMS templates, for SMS text messages that you send from campaigns.

Then, create a campaign or journey to send messages that use the template. When you send the messages, Amazon Pinpoint retrieves the latest data from the Amazon Personalize campaign, and replaces each variable with values that your model recommends for each message recipient.

This feature is available in the following AWS Regions: 
+  US East (N. Virginia)
+ US West (Oregon)
+ Asia Pacific (Mumbai)
+ Asia Pacific (Sydney)
+ Asia Pacific (Seoul)
+ Asia Pacific (Singapore)
+ Asia Pacific (Tokyo)
+ Europe (Ireland)
+ Canada (Central)

The topics in this chapter explain how to configure Amazon Pinpoint to use recommendation data from an Amazon Personalize campaign. They also explain how to include that data in messages.

**Topics**
+ [How recommendations work in Amazon Pinpoint](ml-models-rm-how-it-works.md)
+ [Preparing to use a recommender model with Amazon Pinpoint](ml-models-rm-prerequisites.md)
+ [Setting up a recommender model in Amazon Pinpoint](ml-models-rm-setup.md)
+ [Using recommendations in messages](ml-models-rm-using.md)
+ [Managing machine learning models in Amazon Pinpoint](ml-models-managing.md)

# How recommendations work in Amazon Pinpoint
<a name="ml-models-rm-how-it-works"></a>

In a typical workflow, your team performs a series of activities to create and use a recommender model with Amazon Pinpoint. In general, those activities are:

1. In Amazon Personalize, create a solution for the model and deploy it as an Amazon Personalize campaign. Then train, evaluate, and update the model in a continuous cycle to refine the predictions and recommendations that it makes. 

1. Configure Amazon Pinpoint to connect to the Amazon Personalize campaign. Use the configuration settings for the connection to specify how you want to retrieve and process data from the Amazon Personalize campaign.

1. Create one or more email, push notification, or SMS message templates. Design those templates to include message variables that refer to recommended attributes. A *message variable* is a placeholder that refers to a specific attribute. A *recommended attribute* is an attribute that temporarily stores data that Amazon Pinpoint retrieves from an Amazon Personalize campaign.

1. Create one or more Amazon Pinpoint campaigns that use the message templates. Or, if you created email templates in the preceding activity, create one or more journey activities that use those templates.

After your team performs these activities, Amazon Pinpoint does the following each time it sends a message that includes recommendations from the model:

1. Evaluates the settings and contents of the message and message template.

1. Determines that you connected the message template to a recommender model.

1. Checks the configuration settings that you entered for using the recommender model.

1. Finds one or more message variables for recommended attributes that you created for the recommender model.

1. Connects to the Amazon Personalize campaign that you specified in the configuration settings for the recommender model.

1. For each message recipient:

   1. Retrieves recommendations from the Amazon Personalize campaign.

   1. Adds the recommendations to the recommended attributes that you created for the recommender model.

   1. Replaces each message variable with the corresponding value of the recommended attribute. If you configured the model to enhance recommendations by using an AWS Lambda function, Amazon Pinpoint uses that function as part of this step.

1. Sends a version of the message that contains the personalized recommendations for each message recipient.

# Preparing to use a recommender model with Amazon Pinpoint
<a name="ml-models-rm-prerequisites"></a>

To work with Amazon Pinpoint, a recommender model must be deployed as an Amazon Personalize campaign. In addition, certain AWS Identity and Access Management (IAM) roles and policies must be in place. If you want to enhance the recommendations that Amazon Pinpoint receives from the model, an AWS Lambda function also must be in place to process the recommendations.

Before you set up a recommender model in Amazon Pinpoint, work with your data science and development teams to design and create these resources. Also, work with those teams to make sure that the model meets certain technical requirements to work with Amazon Pinpoint. After you create these resources, work with your administrator to make sure that you and Amazon Pinpoint can access them. As you take these steps, gather the information that you will need to set up the model in Amazon Pinpoint. 

**Topics**
+ [Amazon Personalize campaigns](#ml-models-rm-prerequisites-personalize)
+ [AWS Identity and Access Management roles and policies](#ml-models-rm-prerequisites-iam)
+ [AWS Lambda functions](#ml-models-rm-prerequisites-lambda)

## Amazon Personalize campaigns
<a name="ml-models-rm-prerequisites-personalize"></a>

Amazon Personalize is an AWS service that's designed to help you create machine learning (ML) models that provide real-time, personalized recommendations for customers who use your applications. Amazon Personalize guides you through the process of creating and training a machine learning model, primarily by using a combination of data and a recipe. A *recipe* is an algorithm that's configured to support a specific use case, such as predicting items that a person will like and interact with.

This combination of data and a recipe is referred to as a *solution*. After a solution is trained, it becomes a *solution version*. The solution version is then tested, refined, and prepared for use. When a solution version is ready for use, it's deployed as an Amazon Personalize campaign. The campaign is then used to provide real-time, personalized recommendations. To learn more about Amazon Personalize, see the [Amazon Personalize Developer Guide](https://docs.aws.amazon.com/personalize/latest/dg/what-is-personalize.html).

For Amazon Pinpoint to retrieve recommendations from an Amazon Personalize campaign, the campaign and its components have to meet the following requirements:
+ The recipe has to be a *USER\$1PERSONALIZATION* recipe. It can use any supported algorithm settings (hyperparameters) for this type of recipe. For information about this type of recipe, see [Using predefined recipes](https://docs.aws.amazon.com/personalize/latest/dg/working-with-predefined-recipes.html) in the *Amazon Personalize Developer Guide*.
+ The solution has to be trained using user IDs that can be correlated with endpoint IDs or user IDs in Amazon Pinpoint projects. Amazon Pinpoint uses the `userId` field in Amazon Personalize to correlate data between users in Amazon Personalize and endpoints or users in Amazon Pinpoint projects.
+ The solution has to support use of the [GetRecommendations](https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetRecommendations.html) operation of the Amazon Personalize Runtime API.
+ The campaign has to use the solution version that you want to retrieve recommendations from. 
+ The campaign has to be deployed and have a status of *active*.
+ The campaign has to be running in the same AWS Region as the Amazon Pinpoint projects that will use recommendations from it. Otherwise, Amazon Pinpoint won't be able to retrieve recommendations from the campaign, which could cause an Amazon Pinpoint campaign or journey activity to fail.

In addition to these requirements, we recommend configuring the campaign to support at least 20 provisioned transactions per second.

As you work with your team to implement an Amazon Personalize campaign that meets the preceding requirements, also be sure to answer the following questions:

**Which campaign?**  
To set up the model in Amazon Pinpoint, you will need to know the name of the Amazon Personalize campaign to retrieve recommendations from. Later, if you work with your administrator to manually configure access to the campaign, you will also need to know the Amazon Resource Name (ARN) of the campaign.

**Which type of ID?**  
When you set up the model in Amazon Pinpoint, you choose whether to associate users in the Amazon Personalize campaign with endpoints or users in your Amazon Pinpoint projects. This enables the model to provide recommendations that are truly specific to a particular message recipient.  
In an Amazon Personalize campaign, each user has a user ID (`userId` or `USER_ID`, depending on the context). This is a sequence of characters that uniquely identifies a particular user in the campaign. In an Amazon Pinpoint project, a message recipient can have two types of IDs:  
+ **Endpoint ID** – This is a sequence of characters that uniquely identifies a destination that you can send messages to—such as an email address, mobile phone number, or mobile device.
+ **User ID** – This is a sequence of characters that uniquely identifies a particular user. Each user can be associated with one or more endpoints. For example, if you communicate with a user by email, SMS, and a mobile app, the user could be associated with three endpoints—one for the user's email address, another for the user's mobile phone number, and another for the user's mobile device. 
When you choose the type of Amazon Pinpoint ID to associate with Amazon Personalize user IDs, choose the type that you use most consistently in your Amazon Pinpoint projects. If you or your application hasn't assigned an ID to an endpoint or user, Amazon Pinpoint can't retrieve recommendations for the endpoint or user. This might prevent Amazon Pinpoint from sending messages to the endpoint or user. Or, it might cause Amazon Pinpoint to send messages that display in unexpected or unwanted ways.

**How many recommendations?**  
Each time Amazon Pinpoint retrieves recommendations, Amazon Personalize returns an ordered list of recommendations for each recipient of a message. You can configure Amazon Pinpoint to retrieve 1–5 of these recommendations for each recipient. If you choose one recommendation, Amazon Pinpoint retrieves only the first item from the list for each recipient—for example, the most highly recommended movie for a recipient. If you choose two recommendations, it retrieves the first and second items from the list for each recipient—for example, the top two recommended movies for a recipient. And so on.  
Your choice for this setting depends primarily on your goals for messages that include recommendations from the model. However, it might also depend on how your team designed the solution and your team's evaluation of the solution's performance. For this reason, work with your team to make sure that you choose an appropriate number for this setting.

**What does a recommendation contain?**  
When Amazon Pinpoint retrieves recommendations, Amazon Personalize returns an ordered list of 1-5 recommended items, depending on how many recommendations you choose to retrieve for each message recipient. Each item consists only of text, such as a product ID or a movie title. However, the nature and contents of these items can vary from one Amazon Personalize campaign to another, based on the design of the underlying solution and the campaign.  
Therefore, it's a good idea to ask your team exactly what content the campaign provides for recommended items. Their answer will probably affect how you design messages that use recommendations from the campaign. If you want to enhance the content that the campaign provides, you might also choose to implement an AWS Lambda function that can perform this task.

## AWS Identity and Access Management roles and policies
<a name="ml-models-rm-prerequisites-iam"></a>

AWS Identity and Access Management (IAM) is an AWS service that helps administrators control access to AWS resources. To learn more about IAM and how it works with Amazon Pinpoint, see [Identity and access management for Amazon Pinpoint](https://docs.aws.amazon.com/pinpoint/latest/developerguide/security-iam.html) in the *Amazon Pinpoint Developer Guide*.

When you set up a recommender model in Amazon Pinpoint, you specify which Amazon Personalize campaign you want to retrieve recommendations from. To choose the campaign, your administrator must first allow you to view the campaigns for your organization's AWS account. Otherwise, the campaign won't appear in the list of campaigns that you can choose from. If you don't see the campaign in the list, ask your administrator to provide you with this access. 

In addition, you or your administrator must create an IAM role and policy that allows Amazon Pinpoint to retrieve recommendations from Amazon Personalize campaigns. When you set up a recommender model, you can choose to have Amazon Pinpoint create this role and policy for you automatically. Another option is for you or your administrator to create this role and policy manually, before you set up the recommender model in Amazon Pinpoint. To learn how to do this, see [IAM role for retrieving recommendations](https://docs.aws.amazon.com/pinpoint/latest/developerguide/permissions-get-recommendations.html) in the *Amazon Pinpoint Developer Guide*.

## AWS Lambda functions
<a name="ml-models-rm-prerequisites-lambda"></a>

For some models, you might want to enhance the recommendations that Amazon Pinpoint receives from Amazon Personalize. For example, instead of including only a single recommended value (such as a product name) in messages, you might want to include additional content (such as a product's name, description, and image) in messages. You can do this by working with your team to design and create an AWS Lambda function that transforms recommendation data into the content that you want.

AWS Lambda is an AWS service that's designed to help people run code without provisioning or managing servers. You or your team develops and packages code, and uploads it to AWS Lambda as a Lambda function. AWS Lambda then runs the function each time the function is invoked by an application or service, such as Amazon Pinpoint. To learn more about AWS Lambda, see the [AWS Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html).

When you set up a recommender model in Amazon Pinpoint, you specify how you want Amazon Pinpoint to process the recommendations that it receives. One option is to use a Lambda function. If you want to use a Lambda function, work with your team to: 
+ Define what the function does.
+ Define the custom recommended attributes that you want the function to use when it processes recommendations. This includes the number of attributes, and the name and purpose of each one. A Lambda function can use as many as 10 custom attributes for each message recipient. You will need to enter information about these attributes when you set up the recommender model in Amazon Pinpoint.
+ Make sure that the function is hosted in the same AWS Region as the Amazon Pinpoint projects that will use it. Otherwise, Amazon Pinpoint won't be able to send recommendation data to the function, which could cause an Amazon Pinpoint campaign or journey activity to fail.

Finally, work with your administrator to create a policy that allows Amazon Pinpoint to invoke the Lambda function each time it sends messages that include recommendations from the model. 

For detailed information about using a Lambda function to process recommendations, see [Customizing recommendations with AWS Lambda](https://docs.aws.amazon.com/pinpoint/latest/developerguide/ml-models-rm-lambda.html) in the *Amazon Pinpoint Developer Guide*.

# Setting up a recommender model in Amazon Pinpoint
<a name="ml-models-rm-setup"></a>

A *recommender model* is a type of machine learning (ML) model that's designed to predict what a particular user will prefer from a given set of products or items. It provides that information as a set of recommendations for the user. In Amazon Pinpoint, you can use these models to send personalized recommendations to message recipients based on each recipient's attributes and behavior.

Before you can use a recommender model in this way, you must set up a connection between Amazon Pinpoint and the Amazon Personalize campaign that has the model to use. When you set up the connection, you specify how you want to retrieve and use recommendations from the Amazon Personalize campaign. You also add settings for attributes that temporarily store recommendations from the campaign.

## Before you begin
<a name="ml-models-rm-setup-prerequisites"></a>

Before you set up a recommender model in Amazon Pinpoint, review the information in [Preparing to use a recommender model with Amazon Pinpoint](ml-models-rm-prerequisites.md). This will help you gather the resources and information that you need to set up the model in Amazon Pinpoint.

## Step 1: Set up the model
<a name="ml-models-rm-setup-step1"></a>

For this step, you specify which Amazon Personalize campaign you want to retrieve recommendations from. You also choose settings that specify how you want to retrieve and use those recommendations.

**To set up a recommender model**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Machine learning models**.

1. On the **Machine learning models** page, choose **Add recommender model**.

1. Under **Model details**, for **Recommender model name**, enter a name for the model in Amazon Pinpoint. The name must begin with a letter or number. It can contain up to 128 characters. The characters can be letters, numbers, underscores (\$1), or hyphens (‐).

1. (Optional) For **Recommender model description**, enter a brief description of the model. The description can contain up to 128 characters. The characters can be letters, numbers, spaces, or the following symbols: underscores (\$1), semicolons (;), parentheses (), commas (,), and hyphens ( ‐).

1. Under **Model configuration**, for **IAM role**, choose the AWS Identity and Access Management (IAM) role that authorizes Amazon Pinpoint to connect to and retrieve recommendations from the Amazon Personalize campaign that uses the model. You have the following options:
   + **Use an existing role** – Choose this option to use an IAM role that already exists for your AWS account. Then, from the list of roles, choose the role that you want.
   + **Automatically create a role** – Choose this option to automatically create an IAM role that has the required permissions. Then, enter a name for the role.

   Another option is to work with your administrator to create the role manually. For information about creating the role manually, see [IAM role for retrieving recommendations](https://docs.aws.amazon.com/pinpoint/latest/developerguide/permissions-get-recommendations.html) in the *Amazon Pinpoint Developer Guide*.

1. For **Recommender model**, choose the Amazon Personalize campaign that you want to retrieve recommendations from.

   This list displays all the Amazon Personalize campaigns that you're allowed to access with your AWS account in the current AWS Region. If the list doesn't include the campaign that you want, ask your administrator to give you access to the campaign and verify that you chose the correct IAM role in the preceding step. Also, verify that the campaign exists in the current AWS Region.

1. Under **Settings**, for **Identifier to use for recommendations**, specify whether you want to associate unique users in the Amazon Personalize campaign with endpoints (**Endpoint ID**) or users (**User ID**) in your Amazon Pinpoint projects.

1. For **Number of recommendations per message**, choose the number of recommended items that you want to retrieve for each endpoint or user in your Amazon Pinpoint projects, depending on your choice in the preceding step. 

   This setting determines how many recommendations Amazon Pinpoint retrieves and you can add to individual messages. You can retrieve as many as five recommended items. If you choose **1**, Amazon Pinpoint retrieves only the first item from the list of recommendations for each message recipient—for example, the most highly recommended movie for a recipient. If you choose **2**, it retrieves the first and second items from the list for each recipient—for example, the top two recommended movies for a recipient. And so on, for as many as five recommendations.

1. For **Processing method**, choose one of the following options to specify how you want Amazon Pinpoint to process the recommendations that it retrieves:
   + **Use the value returned by the model** – With this option, messages display the exact text of the recommendations that are provided by the Amazon Personalize campaign. In addition, all the recommendations for each endpoint or user are temporarily stored in one standard recommended attribute for each endpoint or user.
   + **Use a Lambda function** – With this option, messages can display enhanced recommendations instead of or in addition to the text of the recommendations that are provided by the Amazon Personalize campaign. If you choose this option, Amazon Pinpoint sends recommendations to an AWS Lambda function for additional processing, before it sends a message that includes the recommendations. In addition, you can temporarily store recommendations in as many as 10 custom recommended attributes for each endpoint or user.

     If you choose this option, also use the **Lambda function** list to choose the function that you want to use. This list displays all the Lambda functions that you're allowed to access with your AWS account in the current AWS Region. If the list doesn't include the function that you want, ask your administrator to give you access to the function. If the function doesn't exist yet, choose **Create new Lambda function**, and work with your development team to create the function. For more information, see [Customizing recommendations with AWS Lambda](https://docs.aws.amazon.com/pinpoint/latest/developerguide/ml-models-rm-lambda.html) in the *Amazon Pinpoint Developer Guide*.

1. When you finish entering these settings, choose **Next** to proceed to the next step—adding attribute settings for the recommender model. 

## Step 2: Add attributes to the model
<a name="ml-models-rm-setup-step2"></a>

After you choose settings for connecting to and retrieving recommendations from the Amazon Personalize campaign, you're ready to enter settings for the attributes that will store the recommendation data. These options vary depending on the processing method that you chose in the preceding step:

**Use the value returned by the model**  
If you chose this option, recommendations are temporarily stored in one attribute. This is a standard recommended attribute for each endpoint or user, depending on the option that you chose for the **Identifier to use for recommendations** setting in the preceding step. The underlying name of this attribute is `RecommendationItems`.  
For **Display name**, enter a descriptive name for the attribute. This name will appear in the **Attribute finder** in the template editor when you add a variable for the attribute to a message template. The name can contain up to 25 characters. The characters can be letters, numbers, spaces, underscores (\$1), or hyphens (‐).

**Use a Lambda function**  
If you chose this option, you can use as many as 10 attributes to store data for each recommendation. These are custom recommended attributes for each endpoint or user, depending on the option that you chose for the **Identifier to use for recommendations** setting in the preceding step. For example, if you retrieve one product recommendation for each endpoint or user, the Lambda function can process the recommendation and add the results to three custom attributes for the recommendation—product name, price, and image.  
For each custom attribute that you want to add, choose **Add attribute**, and then do the following:  
+ For **Attribute name**, enter a name for the attribute. This name, preceded by the `Recommendations` prefix, will appear in the template editor after you add a variable for the attribute to a message template. The name has to match the name of an attribute that the Lambda function uses to store recommendation data.

  An attribute name has to start with a letter or number and it can contain up to 50 characters. The characters can be letters, numbers, underscores (\$1), or hyphens (‐). Attribute names are case sensitive and must be unique.
+ For **Display name**, enter a descriptive name for the attribute. This name will appear in the **Attribute finder** in the template editor when you add a variable for the attribute to a message template. The name has to start with a letter or number and it can contain up to 25 characters. The characters can be letters, numbers, spaces, underscores (\$1), or hyphens (‐).

When you finish entering attribute settings, choose **Next** to proceed to the next step—reviewing and publishing the configuration settings for the recommender model.

## Step 3: Review and publish the model
<a name="ml-models-rm-setup-step3"></a>

After you finish entering all the settings for connecting to and using the recommender model, you're ready to review the settings.

When you finish reviewing the settings, choose **Publish** to save them. Amazon Pinpoint then checks the settings to verify that they're correct. If any settings are missing or incorrect, it displays a message for each error to help you determine which setting to fix. If you need to fix a setting, use the navigation pane to go directly to the page that contains the setting.

After you publish the settings, you can start using recommendations in messages.

# Using recommendations in messages
<a name="ml-models-rm-using"></a>

To add dynamic, personalized recommendations to messages, create and use message templates that include message variables for recommended attributes. A *message variable* is a placeholder that refers to a specific attribute that you or Amazon Pinpoint created to store information about your users. A *recommended attribute* is an attribute that temporarily stores recommendations for your users. Amazon Pinpoint retrieves these recommendations from a recommender model that you deployed as an Amazon Personalize campaign and configured Amazon Pinpoint to use.

If a template contains message variables, Amazon Pinpoint replaces each variable with the current, corresponding value of the attribute for each recipient. For recommendations, this process includes retrieving the latest recommendations for each recipient from an Amazon Personalize campaign. Amazon Pinpoint does this each time it sends a message that uses the template. This means that you can feel confident that the message contains the latest recommendations for a recipient.

For example, if your project is an application that recommends movies and TV shows to users, you might have the following attributes for each user:
+ The user's first name.
+ The rating that the user most recently submitted.
+ The title of the movie or show that the user most recently rated.
+ The titles of the top three movies and shows that the model recommends for the user.

For this project, you could use the following text and message variables in a template:

`Hi {{User.UserAttributes.FirstName}}, based on your recent {{User.UserAttributes.LatestRating}}-star rating for {{User.UserAttributes.LatestRatedTitle}}, we think you might also enjoy: {{RecommendationItems.[0]}}, {{RecommendationItems.[1]}}, and {{RecommendationItems.[2]}}.`

When you send a message that uses the template, Amazon Pinpoint replaces the variables with the current value of each attribute for each recipient. The following examples show this.

**Example 1**  
`Hi Sofia, based on your recent 5-star rating for The Marvelous Mrs. Maisel – Season 3, we think you might also enjoy: Fleabag, Late Night, and Catastrophe.`

**Example 2**  
`Hi Alejandro, based on your recent 4-star rating for Tom Clancy's Jack Ryan – Season 2, we think you might also enjoy: Hanna, Hunters, and Agatha Christie's The ABC Murders.`

If you configured a recommender model to enhance recommendations by using an AWS Lambda function, a template and the resulting message might use additional variables and recommended attributes. For example, they might also use variables for attributes that provide an image and a URL for each recommended movie or show.

For more information about using message variables in templates, see [Adding personalized content to message templates](message-templates-personalizing.md).

## Adding recommendations to messages
<a name="ml-models-rm-using-add-variables"></a>

To add personalized recommendations to messages, create and use message templates that include message variables for the recommendations that you want to use. You can add these variables to the following types of message templates:
+ Email templates, for email messages that you send from campaigns or journeys.
+ Push notification templates, for push notifications that you send from campaigns.
+ SMS templates, for SMS text messages that you send from campaigns.

Each template can use variables and recommended attributes from one recommender model at a time.

You can add the variables to a new template when you create the template, or to an existing template. If you add variables to an existing template, Amazon Pinpoint doesn't necessarily apply the changes to messages that use the template and haven't been sent yet, such as campaign messages that are scheduled to be sent at a later time. This depends on the version of the template that you add variables to and how you configured the messages that use the template. For more information, see [Managing versions of message templates](message-templates-versioning.md).

**To add recommendations to a message template**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Message templates**.

1. On the **Message templates** page, do one of the following: 
   + To create a new template and add recommendations to it, choose **Create template**. Then, on the template page, enter a name for the template and, optionally, a description of the template.
   + To add recommendations to an existing template, choose the template that you want. Then, on the template page, choose **Edit**. Under **Template details**, use the version selector to choose the version of the template that you want to use as a starting point. If you choose the most recent version, you can save your changes directly to that version of the template. Otherwise, you can save your changes as a new version of the template.

1. In the **Attribute finder**, expand the **Recommended attributes** section.

   If you haven't selected a recommender model for the template yet, choose **Connect model**. Next, select the model that you want to retrieve recommendations from when you send messages that use the template. Then choose **Connect model**.

1. Under **Recommended attributes**, choose the attribute that you want to add a message variable for. Amazon Pinpoint creates a variable for the attribute and copies it to your clipboard. Then, in the message editor, paste the variable where you want the recommendation to appear in messages.

   After you paste the variable, Amazon Pinpoint displays it as the name of the associated attribute, enclosed in two sets of curly braces—for example, `{{RecommendationItems}}`.

1. If the recommender model provides more than one recommended attribute, repeat the preceding step for each additional attribute that you want to add a variable for.

   You can also add variables for other types of attributes. To do this, expand other sections in the **Attribute finder**, choose each additional attribute that you want, and then paste the variable in the location that you want. To learn about using variables for other types of attributes, see [Adding personalized content to message templates](message-templates-personalizing.md).

1. To specify a default value for a message variable, expand the **Default attribute values** section. Then, in the list of variables, enter the default value that you want to use for the variable. We recommend that you do this for each variable in the template.

1. When you finish, do one of the following:
   + If you added message variables to a new template, choose **Create**.
   + If you added message variables to an existing template and you want to save your changes as a new version of the template, choose **Save as new version**.
   + If you added message variables to an existing template and you want to save your changes as an update to the most recent version of the template, choose **Update version**. This option is available only if you opened the most recent version of the template in step 3.

You can now use the template to include personalized recommendations in messages that you send from campaigns and journeys.

Note that you can't include recommendations in messages that you send to a limited audience as direct or test messages. Although you can use templates in these messages more generally, Amazon Pinpoint can't correlate recommendations from a model with recipients of a direct or test message. To test the appearance and formatting of a template that uses recommendations, specify a default value for each message variable that refers to a recommended attribute, and then send a test message that uses the template.

## Removing recommendations from messages
<a name="ml-models-using-remove-variables"></a>

To remove personalized recommendations from messages, update the message template that the messages use. When you update the template, remove all or only some message variables for recommendations.

If you remove recommendations from a template, Amazon Pinpoint doesn't necessarily apply the changes to messages that use the template and haven't been sent yet, such as campaign messages that are scheduled to be sent at a later time. This depends on the version of the template that you remove recommendations from and how you configured the messages that use the template. For more information, see [Managing versions of message templates](message-templates-versioning.md).

**To remove recommendations from a message template**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Message templates**.

1. On the **Message templates** page, choose the template that you want to remove recommendations from. Then, on the template page, choose **Edit**.

1. Under **Template details**, use the version selector to choose the version of the template that you want to use as a starting point. If you choose the most recent version, you can save your changes directly to that version of the template. Otherwise, you can save your changes as a new version of the template.

1. In the message editor, delete all the text of the message variable for each recommended attribute that you want to remove. Each message variable consists of two sets of curly braces and the name of the associated attribute—for example, `{{RecommendationItems}}`.

   To remove the recommender model from the template completely, delete all the variables for recommended attributes that the model provides. Then, in the **Attribute finder**, expand the **Recommended attributes** section and choose **X** next to the name of the model.

1. When you finish, do one of the following:
   + To save your changes as a new version of the template, choose **Save as new version**.
   + To save your changes as an update to the most recent version of the template, choose **Update version**. This option is available only if you chose the most recent version of the template in step 4.

# Managing machine learning models in Amazon Pinpoint
<a name="ml-models-managing"></a>

The **Machine learning models** page on the Amazon Pinpoint console provides a single location for you to view, change, and manage Amazon Pinpoint configuration settings for all the machine learning (ML) models that you've connected to your Amazon Pinpoint account in the current AWS Region. By using this page, you can perform management tasks such as viewing, changing, and deleting configuration settings for connections to ML models. You can also configure Amazon Pinpoint to connect to and use data from additional ML models.

**Topics**
+ [Viewing your collection of models](#ml-models-managing-view-all)
+ [Viewing the settings for a model](#ml-models-managing-open)
+ [Changing the settings for a model](#ml-models-managing-change)
+ [Copying a model](#ml-models-managing-copy)
+ [Deleting a model](#ml-models-managing-delete)

To learn how to add and configure a connection to a model, see [Setting up a recommender model in Amazon Pinpoint](ml-models-rm-setup.md).

## Viewing your collection of models
<a name="ml-models-managing-view-all"></a>

The **Machine learning models** page displays a list of all the configurations that you created to enable Amazon Pinpoint to connect to and use data from specific ML models for your account. To browse the list or find specific configurations quickly, you can sort and filter the list, choose which columns to display, and change other display settings for the list.

**To view your collection of ML models**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Machine learning models**. The **Machine learning models** page opens and displays the number of configurations in your collection and a list of those configurations.

1. To customize the list or find a specific configuration quickly, choose any of the following options:
   + To sort the list by a specific type of value, click the column heading for that value. To change the sort order from ascending to descending or vice versa, click the column heading again. 
   + To apply a filter that displays only those configurations whose names contain specific text, enter the text in the **Search** box above the list. To remove the filter, choose **X** in the **Search** box.
   + To change the number of configurations that are displayed in the list, choose the settings icon at the top of the page. Then, for **Page size**, choose the number of configurations that you want to display, and choose **Save changes**.
   + To add or remove columns from the list, choose the settings icon at the top of the page. Then, for **Choose visible columns**, turn each column on or off, and choose **Save changes**.

## Viewing the settings for a model
<a name="ml-models-managing-open"></a>

By using the **Machine learning models** page, you can quickly find and open a specific configuration to view its settings and other information. For example, you can view a list of the attributes that the model provides for use in messages. After you open a configuration to view its settings, you can also [change the settings for the configuration](#ml-models-managing-change).

**To view the settings for an ML model**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Machine learning models**.

1. On the **Machine learning models** page, choose the configuration whose settings you want to view.

The configuration page opens and displays the current settings for the configuration.

## Changing the settings for a model
<a name="ml-models-managing-change"></a>

Before you change the configuration settings for an ML model, it's important to note that Amazon Pinpoint automatically applies your changes to message templates that use the model. (It applies the changes to both the active and latest versions of the template.) This means that your changes also affect any messages that use those templates and haven't been sent yet, such as campaign messages that are scheduled to be sent at a later time.

For this reason, your changes might prevent Amazon Pinpoint from sending messages that use the configuration and haven't been sent yet. Or, your changes could cause those messages to display in unexpected or unwanted ways. This depends on the configuration settings that you change. It also depends on how you designed the templates that use the model.

If you change the configuration settings for an ML model, be sure to also review and make the appropriate changes to any templates that use the current configuration for the model. For example, if you delete an attribute, be sure to also remove or replace that attribute in every template that uses the attribute. Also, be sure to make those changes to the appropriate versions of each message template. For more information, see [Editing a message template](message-templates-managing-edit.md).

If you don't want to apply your changes to existing templates and messages, you can [create a copy of the configuration](#ml-models-managing-copy), and save the copy with the changes that you want. You can then use the configuration copy in new templates, or update existing templates to use the configuration copy.

**To change the settings for an ML model**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Machine learning models**.

1. On the **Machine learning models** page, choose the configuration that you want to change. The configuration page opens and displays the current settings for the configuration.

1. Choose **Edit model**.

1. On the **Set up model** page, make your changes. You can change any of the settings, except the name of the configuration. To change the name of the configuration, you can [create a copy of the configuration](#ml-models-managing-copy), save the copy with the name that you want, and then optionally [delete the original configuration](#ml-models-managing-delete).

1. When you finish changing these settings, choose **Next**.

1. On the **Add attributes** page, make your changes, and then choose **Next**.

1. On the **Review and publish** page, review the new settings and make sure that they're what you want. If they are, choose **Publish** to save your changes.

## Copying a model
<a name="ml-models-managing-copy"></a>

To quickly create a new configuration that's similar to an existing configuration for an ML model, you can create a copy of the configuration. You can then change settings for the configuration copy, without changing the original configuration.

**To copy an ML model**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose **Machine learning models**.

1. On the **Machine learning models** page, select the check box next to the configuration that you want to copy.

1. On the **Actions** menu, choose **Duplicate**.

1. For **Recommender model name**, enter a name for the configuration copy. The name has to begin with a letter or number. It can contain up to 128 characters. The characters can be letters, numbers, underscores (\$1), or hyphens (‐). 

1. When you finish entering the name, choose **Duplicate model**. The configuration page opens and displays the current settings for the configuration that you copied.

1. (Optional) To change the configuration copy, choose **Edit model**, and then make your changes. When you finish, choose **Publish**.

## Deleting a model
<a name="ml-models-managing-delete"></a>

If you want to remove the configuration for an ML model from Amazon Pinpoint completely, you can delete the configuration. When you delete a configuration, Amazon Pinpoint deletes all settings for the configuration and the configuration becomes unavailable for use in both new and existing message templates. You can't recover a configuration after you delete it.

**Warning**  
If you delete a configuration, Amazon Pinpoint won't be able to send messages that use the configuration and haven't been sent yet, such as campaign messages that are scheduled to be sent at a later time. Before you delete a configuration, review and update the contents and settings for message templates that use the configuration. Also, review any campaigns and journey activities that use those templates, and update them as necessary. 

If you delete a configuration, Amazon Pinpoint doesn't delete any resources or data that's used by the configuration and stored in other AWS services. This includes Amazon Personalize solutions and campaigns, and any AWS Lambda functions.

**To delete an ML model**

1. Open the Amazon Pinpoint console at [https://console.aws.amazon.com/pinpoint/](https://console.aws.amazon.com/pinpoint/).

1. In the navigation pane, choose ** Machine learning models**.

1. On the **Machine learning models** page, select the check box next to each configuration that you want to delete.

1. On the **Actions** menu, choose **Delete**.

1. In the window that appears, enter **delete** to confirm that you want to delete the selected configurations, and then choose **Delete models**.

    