AWS Public Sector Blog
Using machine learning to customize your nonprofit’s direct mailings
Many organizations perform direct mailings, designed to support fundraising or assist with other efforts to help further the organization’s mission. When an organization sends a direct mail piece to an individual, the piece typically contains a specific call to action–like contributing a donation or engaging with the organization’s cause.
Direct mailing workflows can use everything from a Microsoft Word mail merge to utilizing a third-party mailing provider. Regardless of the technology used, program administrators generate an address list and provide it to a system that generates mailings. By leveraging the power of the cloud, organizations can take advantage of capabilities that might otherwise be out of reach, like customized personalization at scale. Using personalization in direct mailing efforts can enhance the member experience and improve an organization’s return on investment when the right call to action is sent to the right member.
In this walkthrough, learn how organizations can utilize machine learning (ML) personalization techniques with Amazon Web Services (AWS) to help drive better outcomes on their direct mailing efforts.
Solution overview: Customize nonprofit direct mailings with Amazon Personalize
This walkthrough uses Amazon Personalize, an ML service that can be used by those with no ML experience to generate a personalization experience for their members. You can use Amazon Personalize to build a recommendation model for everything from what television program a member might want to view next to what donation amount a member might want to contribute.
To build a recommendation model, Amazon Personalize needs an interactions dataset, which contains the interactions of a member with an item. Amazon Personalize uses this dataset to build an ML model, which is used to generate recommendations. This dataset must contain a minimum of three fields:
- A USER_ID column, which is the unique identifier for the member
- An ITEM_ID column, which represents the item that the member interacted with
- A TIMESTAMP column, which represents the time of the interaction, in a UNIX epoch time format
With just these three fields, Amazon Personalize can generate an ML model that can recommend items that the member may be most likely to interact with next.
About the solution
To assist program administrators in using personalization in their direct mailings, the solution presented here generates personalization recommendations for members. The high-level architecture of the application is as follows (see Figure 1):
- Through the solution, an administrator uploads a Microsoft Excel document, which contains the mailing list, and some data about member interactions. This solution is hosted in AWS Amplify and uses Amazon Cognito for permissions.
- Using AWS Step Functions, the Excel data is extracted, an ML model is created via Amazon Personalize, and the results are added back to the document and saved to Amazon Simple Storage Service (Amazon S3).
- The administrator receives an email via Amazon Simple Email Service (Amazon SES) with a link to download an updated version of the Excel document, which contains the personalization results.
This new Excel document contains personalization information and can be used in a mail merge or sent to a third-party for generating a mailing.
Figure 1. The architecture of the solution.
Deploying the solution
To build the infrastructure that supports this solution, you can use an AWS CloudFormation template. This template deploys infrastructure to allow an upload of an Excel file, the processing and creation of a personalization ML model, the notification of success or failure of the process, and the appropriate AWS Identity and Access Management (IAM) permissions. Deploy this solution in your environment with this link or through the Launch Stack button. This solution will deploy in the US-East-1 Region.
After selecting the Launch Stack button, the Create stack page from the AWS CloudFormation dashboard within the AWS console opens. Select the Next button that appears at the bottom of the Create stack page.
On the Specify stack details page, provide an email address through which to receive email notifications (Figure 2).
Figure 2. The Specify stack details page, where an email address must be provided.
Continue to choose the Next button until you are taken to the Review page. Check the box that says I acknowledge that AWS CloudFormation might create IAM resources and select the Submit button. The installation begins, which usually takes between 5-10 minutes to complete.
During the installation process, you will receive an email at the address you entered (Figure 3). Make sure to select the link in the email, which will verify the email address you initially provided. This step is necessary so that you receive notifications from this solution.
Figure 3. Email address verification request from Amazon SES.
You will also receive an email with a temporary username and password for the website that allows you to upload an Excel document for personalization. This email will come from no-reply@verificationemail.com. Your username will be the email address you entered, and the password has been auto-generated for you.
Once the solution finishes installing (as indicated by showing a CREATE_COMPLETE status in the CloudFormation console), choose the Outputs tab within CloudFormation. You will see a field labeled WebsiteUrl. This URL can be used to upload Excel documents to this service (Figure 4).
Figure 4. The CloudFormation Outputs tab, which shows a WebsiteUrl field. The WebsiteUrl field can be used to upload an Excel document to receive personalized content.
When you select the URL in the WebsiteUrl field, you’ll be prompted to enter a username and password. Enter the email address you provided previously, and enter the temporary password you received via email. You will be prompted to change the password the first time you log in.
The page that appears provides directions on how to use the upload solution.
Using the solution
To demonstrate the solution, this walkthrough uses a sample Excel document. This solution requires that your Excel workbook contains three sheets:
- A worksheet named Mailing. This sheet contains the mailing information for the direct mailing. This worksheet must contain a field called USER_ID as the first column.
- A worksheet called Interactions. This sheet contains the interactions between the members and the items you wish to recommend. The fields of this worksheet are USER_ID, ITEM_ID, and TIMESTAMP. USER_ID should match the USER_ID column of the Mailing The ITEM_ID column should contain the identifier for the item the user interacted with. The TIMESTAMP column should be the time of the interaction between the member and the item, in a UNIX timestamp format.
- A worksheet called RecommendationText. This sheet contains a unique list of each ITEM_ID and the text you wish to display if that ITEM_ID is recommended to the member. The fields of this worksheet are ITEM_ID, which should correspond to the ITEM_ID of the Interactions worksheet and TEXT, which is the text you wish to display if the item is recommended to the member.
The example Excel document includes five individuals to whom I want to send personalized mailings. I want to recommend the most appropriate call to action for each of these members, based on their previous interaction history. In the case of the sample Excel workbook, this data represents pages on my website that each member has interacted with, and I want to recommend the webpage that the member will most likely want to interact with in the future. However, you should collect interaction data specific to your organization. Some organizations might record member interactions with videos to recommend the video the member will mostly likely want to interact with. Other organizations might want to recommend a specific product to a member based on their interaction history. The personalization model that is created can be unique to your organization and mission.
In this example walkthrough, the Interactions table of the Excel document has each of the member interactions recorded. The items labeled GET_INVOLVED, EVENTS, DONATE, etc. all represent different pages on my website that the member has visited. The personalization model will inspect each of these items and recommend one of them to each member. Finally, the RecommendationText worksheet lists each of the possible recommended items and the text I want to display to a member for each recommendation.
For example, if a member has a recommendation of DONATE, I likely want to provide information on how the member can donate to my organization’s mission. Likewise, if a member has a recommendation of EVENTS, I likely want to provide information about upcoming events.
To run the solution, select the URL that is provided in the WebsiteUrl field in the Outputs tab of the CloudFormation console. After logging in, choose the link that says Click here to upload a new document and begin the personalization process. This takes you to the Mail merge uploader page. Select the Choose file button to select the Excel file to upload, making sure it matches the format specified in the directions. Choose the Add Excel Doc button to begin the process to personalize the data. A message appears on the website stating the document has been uploaded and is being processed (Figure 5).
Figure 5. The upload confirmation message on the Mail merge uploader tool.
Close this browser window and wait for the personalization model to be created.
Behind the scenes, the solution is extracting the data provided in Excel, using Amazon Personalize to create a new personalization ML model, generating predictions, and merging those predictions back into the original Excel document. This process will usually take between 30 to 120 minutes, depending on the amount of data provided.
Once the predictions have been produced, an email is sent to your inbox with a link to download the results. The download link will be valid for a few hours.
The results consist of the original Mailing Excel worksheet with the addition of two columns: ITEM_ID, which represents the specific personalization recommendation for the member; and TEXT, which is the text I specified for that ITEM_ID on the original RecommendationText worksheet (Figure 6).
Figure 6. The Excel results updated with an ITEM_ID and TEXT column, representing the personalization recommendation for each member.
With personalization data now added directly to the mailing information, I can use a mail merge within Word or provide my mailing data to a third-party provider. The TEXT field can be added directly to my direct mailing template to make sure that each member receives the most appropriate and targeted call to action.
Clean up
To avoid on-going charges to your AWS account, remove the resources created via this solution by using the CloudFormation console to delete the stack created as part of this demo. Choose the stack, select Delete, and then select Delete stack.
Cost considerations
With Amazon Personalize, you pay only for what you use. AWS charges you based on the amount of data stored, the training hours used to train a model, and the number of recommendations you make. For current pricing details and some sample pricing scenarios, see the Amazon Personalize pricing page.
This solution uses AWS Step Functions to orchestrate the workflow. With AWS Step Functions, you pay for the number of state transitions required to execute the application. This application uses approximately 200 state transitions per execution, which is well within the AWS Free Tier. For current pricing details, see the AWS Step Functions pricing page.
This solution uses AWS Lambda as a compute solution. With AWS Lambda, you pay for the compute time in seconds as well as the number of requests. For this solution, the AWS Lambda usage falls under the AWS Free Tier. For current pricing details, see the AWS Lambda pricing page.
This solution uses Amazon S3 for storage. With Amazon S3, you pay for the total storage, requests, and data retrievals, and the amount of data transfer. For current pricing details, see the Amazon S3 pricing page.
This solution uses AWS Amplify for hosting of the Excel uploader application. With AWS Amplify hosting, you pay for data storage, data transfer out, the number of requests, and the duration of those requests. This solution is designed to fall under the AWS Free Tier. For current pricing details, see the AWS Amplify pricing page.
This solution uses Amazon Cognito for authentication and authorization of the Excel uploader application. With Amazon Cognito, you pay for the number of active users. This solution is designed to fall under the AWS Free Tier. For current pricing details, see the Amazon Cognito pricing page.
What’s next
ML tools like Amazon Personalize can help nonprofits make sure their members and community get the most pertinent recommendations in their direct mailings, for donations, event registration, content engagement, and more. The solution presented in this walkthrough can help program administrators simplify these personalization efforts by uploading an Excel document used for direct mailing efforts. The solution adds personalization information to the uploaded Excel document, which can then be integrated with a current direct mailing workflow, and can help make sure the most relevant call to action is added to each member direct mail piece.
As a next step, begin using this solution today to help your member communications focus on the most relevant call to action. By personalizing your member communications–whether digital or direct mail–you create a better experience for your members and support the best return on your marketing investments.
Nonprofits of all sizes are using AWS to increase support, expand awareness, and advance mission impact locally and globally. AWS is dedicated to a world where every person has the opportunity to live a life of dignity on a healthy planet. Learn more at AWS for Nonprofits.
Read more about AWS for nonprofits:
- Creating a video storage and management system for your nonprofit
- Hosting streaming video for your nonprofit with Video on Demand on AWS
- Best practices for creating highly available workloads
- Managing nonprofit members and donors with CiviCRM on AWS
Subscribe to the AWS Public Sector Blog newsletter to get the latest in AWS tools, solutions, and innovations from the public sector delivered to your inbox, or contact us.
Please take a few minutes to share insights regarding your experience with the AWS Public Sector Blog in this survey, and we’ll use feedback from the survey to create more content aligned with the preferences of our readers.