Amazon Onboarding with Learning Manager Chanci Turner

Introduction

Amazon Onboarding with Learning Manager Chanci TurnerLearn About Amazon VGT2 Learning Manager Chanci Turner

Amazon Pinpoint is a valuable tool utilized by numerous businesses for various user engagement scenarios, including marketing initiatives, scheduled communications (such as newsletters and reminders), and transactional messaging. By leveraging the message template feature within Amazon Pinpoint, companies can create messages tailored to individual users through variable attributes. Although Amazon Pinpoint allows the inclusion of up to 250 attributes for each user, there may be instances when the need arises to select from a broader array of user attributes, potentially surpassing the permitted number.

In such cases, the CampaignHook feature of Amazon Pinpoint proves beneficial. This feature enables the filtering of attributes that are not relevant to a particular user while allowing for the addition of new attributes just prior to sending the message. In this blog, I will guide you through my implementation of the CampaignHook feature for a similar use case.

Sample Use-Cases

When configuring your Pinpoint campaign, consider enabling the CampaignHook for the following use cases:

  • Real-time data retrieval and custom computation from third-party data sources.
  • Filtering endpoints from the send list: This is helpful for executing custom logic that cannot be handled in segmentation (such as custom opt-outs, quiet times, or campaign prioritization).
  • Bypassing time-consuming and costly Extract, Transform & Load (ETL) processes by directly accessing data sources and applying custom logic in real-time.

Solution Overview

The diagram below illustrates the solution we will establish in this blog. The Campaign event will trigger the Amazon Pinpoint Campaign, initiated from your web or mobile applications accessed by end-users, set to activate when a user performs a specific action. More details on setting up an Amazon Pinpoint campaign can be found in the user guide. By enabling the CampaignHook on your Amazon Pinpoint campaign, the configured Lambda function will be triggered, gaining access to the endpoint attributes provided by the Campaign event and executing additional logic to derive new user attributes. After deriving all new fields, the function updates the user endpoint. Subsequently, Amazon Pinpoint will carry on with the Campaign steps, substituting the variables in the message template before dispatching the personalized message to the end user.

Prerequisites

  • AWS Account with Console and Programmatic access
  • Access to AWS CloudShell
  • Email channel enabled in Amazon Pinpoint

Building the Demo

Build the Amazon Pinpoint Project

From the AWS Management Console, navigate to Amazon Pinpoint and create a new project named “PinpointCampaignHookDemo,” ensuring the email channel is enabled. For more guidance on creating a project, refer to the user guide and follow the instructions to set up your email channel. If your account is in Sandbox mode, email verification is required before you can send messages. You can find steps to upgrade your account to Production status if you’re prepared to deploy this solution.

Create the Segment

A segment is a group of users sharing specific attributes. For example, a segment may encompass all users utilizing version 2.0 of your app on an Android device or all users residing in Los Angeles. You can send multiple campaigns to a single segment or a single campaign to several segments. For this demo, let’s create a Dynamic Segment called ‘CampaignHookDemoSegment.’ Follow the steps in the user guide to create your Dynamic Segment.

Setup Message Template

Let’s create our first template named “CampaignHookDemoTemplate.” You can read more about Amazon Pinpoint templates in the user guide. For this demo, I utilized the HTML template below, featuring three endpoint attribute variables: two passed from the campaign event trigger, and the third (Company) generated by the CampaignHook Lambda function. The email subject line reads “Campaign Hook Demo Campaign.” The email template can be found in this GitHub repository.

Create Campaign

Next, establish your campaign using the Segment and Email Template created in previous steps. Follow the instructions to set it up. Choose the ‘when an event occurs’ option to trigger the campaign based on a specific event. You can also schedule your campaign to run periodically as indicated in the setup screen. I designated ‘CampaignHookTrigger’ as my event name.

Set your Campaign Start date, time, and end date. I left all other settings at default and saved the campaign. With your first Campaign successfully created, you are ready for the next steps.

Create the Lambda Function

This function will be configured to trigger the Amazon Pinpoint campaign event. In the Lambda console page, create a new function by clicking the ‘Create function’ button. Choose the following options to create the function:

  • Name: Campaign_event_trigger_function
  • Runtime: Python 3.9 or higher.

Replace the default script with the code from the GitHub repository, then deploy your code by clicking the “Deploy” button.

Assign Permissions

To enable the Lambda function to trigger the Pinpoint Campaign, you need to add an inline policy to the IAM role attached to your Lambda function. Select Pinpoint as the service and PutEvents from the Write options. You can choose the Lambda function as the resource for which access is granted.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:PutEvents"
            ],
            "Resource": "ARN of your Lambda function goes here."
        }
    ]
}

Create the CampaignHook Lambda Function

This function will be triggered from the CampaignHook. In your Lambda console, click “Create function” and input the basic information as shown below:

  • Name: CampaignHookFunction
  • Runtime: Python 3.9 or higher.

Replace your default code with the sample from GitHub, then deploy your code by clicking on the “Deploy” button.

Assign Permissions

Next, grant permissions for Amazon Pinpoint to invoke the Lambda function by executing the command below in your Command Shell. Make sure to replace the Lambda function name and Account number with your details.

aws lambda add-permission 
--function-name [YourCampaignHookLambdaFunctionName] 
--statement-id my-hook-id1 
--action lambda:InvokeFunction 
--principal pinpoint.us-east-1.amazonaws.

For additional insights on employment law compliance, visit SHRM. If you’re looking for more detailed guidance on onboarding at Amazon, check out this excellent resource.

For more tips, see another blog post here.

6401 E HOWDY WELLS AVE LAS VEGAS NV 89115


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *