To begin, let’s first back up to the Pinpoint Segment we created in part 2. In that article we created a new segment that identified a subset of users by a specific device (iPhone X). At the time, we just chose an arbitrary communication channel. Here, we should modify the segment to use one of three available channels (Push notifications, Email, and SMS) and use that channel to send our campaign message to those segmented device models.

For this example, I’ll use SMS but you can also setup messaging through Email or Push Notifications channels.

Enable SMS Messaging

From your iOS project folder, launch Terminal and type:

$ amplify add notifications

Select SMS. This enables SMS messaging in your Amazon Pinpoint project.

Register a Device for SMS

When targeting our mobile users, we have three channels to choose from. You can register a device with one or more channels using the AWS CLI or the AWS SDK. Each Amazon Pinpoint Endpoint represents a single channel. So, if you had a user device registered for all three channels, that same device would have three different endpoints, one for each channel. When we create segments, we choose only one channel and only one segment per campaign when sending targeted notifications.

Typically, the channel registration would take place when the user first signs up. For example, if we enabled Amazon Cognito Users Pools with email/password signup, we would capture the email at this stage and send the email address to Pinpoint. Since I chose SMS for my channel, I’ll need to update a device endpoint and set the channel type to SMS and provide a valid mobile phone number for the endpoint address. For this demonstration, I’ll update an endpoint using the AWS CLI.

Update an Endpoint Using AWS CLI

I was going to show you how to update an endpoint directly from the client using the AWS SDK for iOS, however, it wasn’t available (not working for me). I’ll update here if that changes. Sorry, the CLI does create some extra steps.

Get the Amazon Pinpoint endpoint-id from the iOS app client using this snippet of code:

2. Define an endpoint request by pasting this into a new endpointrequest.json file. *Don’t forget to change the phone number to match the iPhone device

3. From a Terminal in the same directory as the endpointrequest.json, let’s update the existing endpoint-id we captured from step #1. The application-id can be found in the Pinpoint console application view here.

Update a Pinpoint endpoint using the following AWS CLI command.

Your endpoint should now be associated with a phone number and an iPhone X device.

Create a New Campaign

You can create a segment first, or a campaign. The console will walk you through creating a segment in the campaign page if it doesn’t exist.

From your project directory in Terminal, launch the Amazon Pinpoint Console using AWS Amplify CLI: $ amplify analytics console In the navigation menu, choose Campaigns. Choose New campaign. Complete the four steps as shown.

Create a new Campaign

Specify the Segment

Under Segment, select Create a new segment.

2. Provide an optional name for the segment to reuse it later.

3. For Filter by standard attributes, define which users are using Model > iPhone X. The (2) “iPhone” devices you see here represent apps that have not been updated with our code from part 2, so we only know these users are on an iPhone. How boring is that?!

4. Leave Holdout at 0%.

5. Select Next step.

Compose and Send a Message

Choose Transactional and type in a shore SMS message and select Next step.

Send immediate. Select Next step.

Select Launch campaign.

You should immediately see the results on any iPhone X that has installed your app and provided their phone number:

Incoming short-code SMS from Amazon Pinpoint

Final Thoughts

In this article, we enabled SMS messaging in our Amazon Pinpoint Application using the Amplify CLI. We then created a new Pinpoint Campaign using our iPhone X as a target audience and sent a targeted SMS message to those users. That concludes my 3-part series on collecting user analytics, adding custom demographics and segmenting those users so that we can target users with relevant information. Please leave a comment or suggestions of what you’d like to read here in the future. Thanks for reading!

Resources

AWS Amplify CLI