AWS for Industries

Building multilingual SMS chatbot campaigns to support COVID-19 patients remotely

The expansion of laboratory tests for COVID-19 have provided health systems with tools to screen for the coronavirus in their community. While some patients have tested positive for COVID-19 and were well enough to manage their symptoms and recover at home, healthcare providers have been challenged with identifying individuals who have waited longer than advisable to seek medical care related to worsening respiratory status. To help address this and to reduce the number of preventable complications in individuals managing COVID-19 at home, one health system has provided support for individuals at home is deploying a scalable, SMS-based home monitoring program to check-in with patients that are COVID-19 positive.

This blog post describes an SMS-based, multilingual home monitoring solution that medical centers and hospitals have deployed to check in with and support their COVID-19 patients daily. The solution is built on a clinical protocol that has been defined by healthcare organizations in assessing for COVID-19 related complications. It also allows for escalation to a nursing phone line if worsening symptoms, such as respiratory status is confirmed and supports a workflow for care providers to secure consent and register patients into their specific program.

Upon enrollment, patients can engage via SMS with a conversational chat experience in their preferred language. During the clinical protocol evaluation, should any escalations with care providers be necessary, the solution can connect the patient with a care provider from within the chat experience. The solution can set time parameters for engagement (e.g. 14 days of monitoring) and automatically notify users of opting out, as long as it is within the fixed start and end dates of the Pinpoint campaign determined by the healthcare provider. The below steps demonstrate how to deploy this solution for your organization to support outreach engagement through a multilingual SMS chatbot campaign.

 

AWS Solution and Suggested Deployment

This architecture diagram demonstrated the AWS resources needed for this solution, followed by step-by-step guidance for deployment using CloudFormation (CFN) templates.

Step 1:  Deploy a campaign registration portal. To enable an SMS campaign, you will first follow the documentation to create an Amazon Pinpoint project, request a long code phone number, and enable a two way SMS channel. The self-managed opt-outs will need to be enabled (see figure in Step 6), since we will use Lambda hook function to fulfill opt-ins/outs operations in Step 5. Take a note of both the Pinpoint project ID and phone number, which will be used in this step. The first CFN deployment will set up a registration portal that helps your organization to enroll new endpoints, e.g. COVID-19 patient phone numbers, into SMS campaign program. The deployment will create a REST API, hosted by AWS API Gateway, and an integrated Lambda proxy function, with appropriate permission policies, to perform the following operations:

 

 

The REST API endpoint in this CFN deployment has only one POST method that is deployed to a stage with default name as ‘call’. It will be used by the registration web portal, which includes two static files: a registration form web page and a javascript file. They can be downloaded here and hosted in Amazon S3. You will need to copy out the API endpoint from the Output tab to configure the AJAX call in the javascript file as below:

$.ajax({
    type: 'POST',
    url: '<Your API endpoint>',
    data: data,
    ...
}); 

Once you successfully register the phone number endpoints in the SMS campaign solution, e.g. COVID-19 patients connected by hospitals, they should receive a confirmation text message in their preferred language.

To verify your endpoint has been successfully registered, you can create a campaign segment. Once the segment is created, you can export it out in the CSV format.

Your segment can be filtered by the preferred language as UserInfo, so you can create a separate SMS campaign for multiple groups of people with different preferred languages.

Step 2:  Protect the registration portal (Optional). You can use Amazon Cognito to protect the registration portal by authentication/authorization. For an easy deployment and managed DevOps, you can use this Amplify react app with backend Cognito Authentication. Once you fork this repository, you can simply click on the “Deploy to Amplify Console” button. It will take you to AWS console Amplify deployment directly, which will take a couple of minutes to finish.

Once Amplify deployment is finished, you can make changes to this React app to integrate the registration form within this app. You can make change directly in your fork of GitHub repo, or run the local copy with Amplify CLI. You just need to copy/upload the webpage html plus js file to the public folder of this React app and have a hyperlink to the registration page in App.js file:

Once Amplify deployment is finished, you can make changes to this React app to leverage its pre-built UI component for authentication of registration form. You will need to copy/upload the register.html plus SMSFormHandler.js file to the public folder of this React app and have a hyperlink to the registration page in App.js file:

class App extends Component {
  render() {
    return (
        <a href="/register.html">Register New Contact for SMS</a>
    );
  }
}

The backend Authentication of this React app is a Cognito User+Identify Pool. You will need the Cognito user pool ID to create a new Authorizer for you REST API following the steps documented here.

Step 3:  Using QnA Bot to respond to a SMS message. To respond to user SMS text messages, e.g. evaluate COVID-19 patient symptoms and complications, you can deploy a Question and Answer (QnA) bot to apply the clinical evaluation protocol in the SMS transactional messages. After you deploy the QnA bot, take a note of BotName and BotAlias from the Output tab of CFN deployment, which will be used in Step 6. Once the QnA bot is ready, you can download clinical protocol question document and import it into the QnA bot Content Designer. The questions with ID as covid.checkin.3, covid.checkin.5, and covid.checkin.6 will be configured further in Step 5 to add the Lambda Hook function.

Step 4:  Enable escalation phone call. To enable outbound phone call through Amazon Connect, you can follow this guide to provision a Amazon Connect instance and claim a phone number that will be used for outbound phone call. You can download the contact flow configuration file and create a new custom contact flow by importing it. Make sure the phone number you have claimed is associated with this contact flow. The contact flow will check user defined attribute ‘userPreferredLocale’, then decide how to play prompts and which phone number to transfer to after the outbound call is initiated (the example here only have two different numbers, but you may transfer the call to many different ones)

You will need to take a note of the contact flow ARN (highlighted in red box) and phone number, which will be used in the next step.

Step 5:  Deploy AWS Lambda hook functions. Through this deployment, you will create a set of AWS Lambda hook functions including one for initiating the outbound phone call through Amazon Connect and two for self-managed opt-ins/opt-outs. When you deploy the CFN template, make sure the stack name starts with ‘qna-’ or ‘QNA-’. These prefix of AWS Lambda hook functions are required for QnA bot to trigger them.

The output of this deployment has three AWS Lambda hook functions, which will be copied over to the corresponding question Advanced setting for AWS Lambda hook in QnA Content designer:

  • LambdaHookConnect function for ID covid.checkin.3 with question: we will connect you soon
  • PinpointCampaignOptin function for ID covid.checkin.5 with question: enroll
  • PinpointCampaignOptout function for ID covid.checkin.6 with question: stop

In QnA bot Content designer, you will have each of these three questions with AWS Lambda hook configured. The AWS Lambda hook function will trigger after the question is answered.

Once you have the questions for ‘enroll’ and ‘stop’ set up with Lambda Hook functions which can flip the OptOut attribute for a given Amazon Pinpoint endpoint, you can turn on ‘self-managed opt-outs’ for your two-way SMS in Amazon Pinpoint.  You will not need the carrier level keywords for opt out anymore.

Step 6:  Integrate Amazon Pinpoint with QnA bot. Until now, you have an Amazon Pinpoint project using two-way SMS with a registration system (deployed in Step 1) and a conversational QnA bot with clinical evaluation protocol (deployed in Step 3). Both of them support multiple languages through Amazon Translate API. Next, you will need to integrate them through a SNS channel for two way SMS that is subscribed by an AWS Lambda function that interacts with a QnA Bot. The QnA bot will have questions to trigger AWS Lambda hook functions for self-managed opt-ins/opt-outs and initiating outbound phone call to the SMS user. The following CFN template, named PinpointLexIntegration, should create resources for you.

 

You will need to configure two-way SMS in Amazon Pinpoint using the created SNS topic.

QnA bot supports multiple languages through Amazon Translate, and which language to use is determined by a session attribute named “userPreferredLocale”.  The AWS Lambda function deployed above first retrieves the user preferred language for an Amazon Pinpoint endpoint, then sends the SMS text plus the preferred language attribute to QnA bot through Amazon Lex PostText API.

Step 7:  Automatically opt-out endpoint after certain number of days. The Amazon Pinpoint SMS campaign has a fixed start and end dates, how to automatically opt out phone numbers from campaign according to a rolling time window, e.g. 14 days after opt in? It was achieved by an AWS Lambda function, which can retrieve the Amazon Pinpoint stream log data and check the date difference between the endpoint opt in timestamp and most recent campaign timestamp to determine if it is time to opt out phone number from campaign by flipping the value of OptOut attribute from NONE to ALL. The AWS Lambda function will also send one last message to the patients in their preferred language, to notify the them that they have finished SMS checkin program and they can reply ‘ENROLL’ to enroll back into the campaign. You can deploy the following CFN template to stream out the Amazon Pinpoint events to Amazon S3 storage through Amazon Kinesis Firehose, which will trigger the AWS Lambda function to parse the Amazon S3 object and to flip the value of endpoint OptOut attribute if it is beyond a given age limit and send out the SMS notice.

After deployment, you will need to enable the Amazon Pinpoint event stream and send the events to the Amazon Kinesis Data Firehose created through this deployment.

By taking the above outlined steps, you have deployed a SMS campaign platform using Amazon Pinpoint, enabling your organization to register SMS users on their behalf, support the language they prefer to communicate, and opt them out after a defined number of days.

Conclusion
Technology and tools like the SMS chatbot can provide healthcare organizations with the capabilities to scale their engagement channels across their population for broad outreach, while creating more personalized ways to engage and support their patients. Users can respond and interact using two-way SMS channels with the organization’s chatbot and can easily escalate to speak with call center agents initiated and transferred by Amazon Connect. The applications of this tool extend beyond addressing the current COVID-19 crisis, as more healthcare organizations, both healthcare provider or healthcare payor, are developing new channels for engagement to better personalize the healthcare journey. In doing so, these organizations can engage and empower healthcare consumers in their overall health and wellness goals, condition management programs, population health management programs, or clinical trial initiatives for the communities they serve.  To find the latest development to this solution, check out sms chatbot multilingual repository on GitHub.

If you want to learn more about this solution or other AWS Healthcare offerings, please visit https://aws.amazon.com/health or contact your local sales representative.

Stay well.

 

References
1.       QnA bot features and deployment guide.

2.       Self paced guide for set up Amazon Connect instance for Chatbot.

 

 

Gang Fu

Gang Fu

Gang Fu is a Healthcare Solution Architect at AWS. He holds a PhD in Pharmaceutical Science from the University of Mississippi and has over ten years of technology and biomedical research experience. He is passionate about technology and the impact it can make on healthcare.

Katie Petersen

Katie Petersen

Katie Petersen obtained her Bachelor of Science in Nursing from Illinois Wesleyan University in 2003. Her clinical background is in Oncology nursing. She has worked in clinical informatics over ten years with experience leading electronic health record implementations and optimizations with a focus on the digital experience for clinicians. Katie joined Amazon Web Services in August of 2019 as the worldwide clinical informaticist supporting the business development healthcare team.

Ilya Pupko

Ilya Pupko

Ilya is a Senior Consultant for Amazon Web Services (AWS), at the Global Practice division of the Professional Services, where he leads Digital User Engagement (DUE) specialty. DUE focuses on providing high-scale personalized user engagement and communication across channels and mediums, using analytics and machine learning services. Prior to joining Amazon, Ilya was the VP of Technology and Chief Architect at Jitterbit, the company behind many enterprise and SMB integrations. There, he oversaw strategic customer relationships and provided external architectural and security guidance to modern multi-national backbone companies. He was responsible for the future of product innovation and vision, thought leadership and evangelism, as well as enabling everyone inside and outside the company. Under his watch, Jitterbit has ventured into the API Platform market and has been recognized as a leader in the Gartner Magic Quadrant for Enterprise Integration Platform as a Service (iPaaS). Ilya has almost two decades of deep technical hands-on experience at major international corporations, he speaks multiple languages, and holds a BS/BSE degree and an MBA with a concentration in entrepreneurship, marketing, and global business.

Wilson To

Wilson To

Wilson To obtained his PhD in Pathology from the University of California- Davis, where he led a number of scientific investigations and published discoveries in microcirculatory systems related to vascular diseases using computer-assisted intravital microscopy. He has led teams across startup and corporate environments, receiving international recognition for his global health efforts. Wilson joined Amazon Web Services in October 2016 to lead product management and strategic initiatives, and currently leads business development efforts across the AWS worldwide healthcare practice.