AWS Public Sector Blog

Automating multi-channel communication for school bus delays

Communication with parents is a must for school districts. However, some challenges can hinder streamlined and immediate exchange of information, like when a school encounters an unforeseen event, especially during times of low-staffed administration like before and after school hours. For example, most school districts offer some sort of bus transportation to and from school. But buses can occasionally experience a mechanical breakdown, flat tire, or some other event that delays student transportation. This may leave parents wondering where their student’s bus is and may lead them to phone the school office—only to find that nobody is available to answer the call because of the time of day.

However, cloud-based solutions from Amazon Web Services (AWS) can help. In this blog post, I walk through how to set up a solution that enables school districts to notify a targeted group of parents about school bus breakdowns and delays via the parent’s preferred method of communication (i.e., phone call, SMS, or email), when a bus driver reports it. This solution uses AWS services like Amazon Connect and Amazon Pinpoint to create a solution in which a bus driver can call an automated system, report the bus breakdown, and start an outbound notification to parents notifying them of the event and potential delay. Through the same process, the system notifies parents that the bus is back in service or provides alternate instructions for student pickup.

Solution overview: Automating multi-channel communication for school bus delays

Figure 1. Architecture diagram describing the solution in the blog. Major components are Amazon Connect, Amazon Lex, Amazon Polly, AWS Lambda, and Amazon Pinpoint.

Figure 1. Architecture diagram describing the solution in the blog. Major components are Amazon Connect, Amazon Lex, Amazon Polly, AWS Lambda, and Amazon Pinpoint.

Figure 1 features the solution architecture. In this example use case, if a school bus experiences a mechanical failure and becomes delayed, the bus driver can call a designated hotline number. In the solution, Amazon Connect is the contact center solution hosting the phone number that the bus driver calls. The bus driver interacts with a chatbot built with Amazon Lex. Then, Amazon Connect responds to the caller’s request using Amazon Polly, which uses text-to-speech capabilities. When the bus driver starts the request to notify parents, Amazon Connect launches an Amazon Pinpoint journey via AWS Lambda. Amazon Pinpoint contains segments, or groupings of customers based on attributes, that have parents’ information for all the students on a particular bus. The segment also has the bus number, which the driver is prompted to report while interacting with the automated system. The school administration can upload the segment in the .csv file to the Amazon Pinpoint console. Depending on the parents’ previously designated communication channel preference, Amazon Pinpoint sends out outbound notifications to parents to report the delay.

Prerequisites

To follow along with the solution presented in this blog post, you should be familiar with or have the following AWS services and features:

Solution walkthrough: How to set up automatic multi-channel communication for school bus delays

This walkthrough includes a GitHub repo where you can find the CloudFormation template and more. Before beginning the following walkthrough, make sure to:

1. Sign in to the AWS Management Console.

2. Download the CloudFormation template from the Amazon Simple Storage Service (Amazon S3) location to your local machine.

Enable outbound campaigns

1. Navigate to the AWS Management Console. Open the Amazon Connect To find it, type “Amazon Connect” into the search bar.

Figure 2. Describing how to search for Amazon Connect in AWS Management Console.

Figure 2. Describing how to search for Amazon Connect in AWS Management Console.

2. In the Amazon Connect console, navigate to Telephony and check Enable outbound campaigns. Create a new AWS Key Management Service (AWS KMS) key. Then, select Save to enable outbound campaigns. Save the Amazon Resource Name (ARN) of this AWS KMS key because we will use it later on in CloudFormation.

Figure 3. Where to create the AWS KMS key in the Amazon Connect console.

Figure 3. Where to create the AWS KMS key in the Amazon Connect console.

3. Once outbound campaigns are enabled, download and deploy the CloudFormation template in your account. This CloudFormation template deploys the services needed to run the solution, including the Amazon Connect contact flows, the Lambda functions, and the Amazon Pinpoint p In the following steps, we will further setup these services to run our solution.

Building the Amazon Lex bot

1. Navigate to the Amazon Lex console within the AWS Management Console. If you need help finding it, type “Amazon Lex” into the search bar.

2. Open the menu on the left-hand side. Choose the Bots

3. Select Edu_Demo_Bot under Bots.

4. On the left-hand menu, under Languages, choose Intents.

5. On the right-hand side, select Build to build the Amazon Lex bot.

6. Once the bot has finished building, it is ready to be used in the contact flow.

Figure 4. Example message displayed in the Amazon Lex console once the Amazon Lex bot is successfully built.

Figure 4. Example message displayed in the Amazon Lex console once the Amazon Lex bot is successfully built.

7. After the bot has been built, make sure the Lex alias is associated with Version 1. Under Edu_Demo_Bot, go to Bot Versions.

8. Select Version 1.

9. Scroll to the Associated Aliases, and select Associate Alias with Version.

10. Under Alias, choose Lex-BusDemo-Alias and press Associate to associate the bot.

Verifying email ID

In order to send emails through Amazon Pinpoint journeys, an email address must first be verified within the Amazon Pinpoint console.

1. Find Amazon Pinpoint in the AWS Management Console. To surface it, type “Amazon Pinpoint” in the search bar.

2. Select Manage Projects.

3. Choose the Bus-Pinpoint-Project project that was created by the CloudFormation template.

Figure 5. The Bus-Pinpoint-Project under the Projects tab in Amazon Pinpoint.

Figure 5. The Bus-Pinpoint-Project under the Projects tab in Amazon Pinpoint.

4. Under Email, select Email Identities.

Figure 6. Location of Email Identities in the Amazon Pinpoint console.

Figure 6. Location of Email Identities in the Amazon Pinpoint console.

5. Select Verify email identity.

6. Enter the email address you want to send the utbound campaigns from. Select Verify email address.

Figure 7. Email verification sample.

Figure 7. Email verification sample.

7. You should receive an email with instructions to verify your email ID. Follow the instructions in the email to verify the ID.

Updating segments

1. Create a new .csv file in a text editor. Add in <ChannelType>, <Address>, and <User.UserId> fields.

a. ChannelType: Channel to send the message to (SMS, Email)

b. Address: Phone number or email address to send message to

c. UserId: The user ID of the user to send the message to

Due to an influx of requests ahead of the deadline, the blog has reached its publication capacity for 2023. There is a freeze on evaluating new pitches outside of re:Invent until 2023 posts are closed (approximately mid-November). Someone from the AWS PS blog team will evaluate your ticket at that time or you're welcome to close this ticket and re-open once the freeze is lifted.

Figure 8. Overall segment format.

2. Add in your values for the SMS endpoint. The Endpoint should be formatted like below.

ChannelType,Address,User.UserId

SMS,<YOUR_PHONE_NUMBER>,<YOUR_USER_ID>

The following image shows an example .csv as well.

Figure 9. SMS segment format.

Figure 9. SMS segment format.

3. Add your values for the email endpoint. If your account is in the sandbox, enter the email ID that you verified in the previous step.

Figure 10. Email and SMS segment example.

Figure 10. Email and SMS segment example.

4. Your final .csv should have the following format.

ChannelType,Address,User.UserId

SMS,<YOUR_PHONE_NUMBER>,<YOUR_USER_ID>

EMAIL,<YOUR_EMAIL>,<YOUR_USER_ID>

The following is an example of a finished segment:

Figure 11. Email and SMS segment example.

Figure 11. Email and SMS segment example.

5. Create a new .csv file in a text editor for the voice segment. Add in <ChannelType>, <Address>, and <User.UserId> fields.

6. Add your values for the voice endpoint.

Figure 12. Format for voice segment.

Figure 12. Format for voice segment.

7. Your final .csv should have the following format. The following sample image shows a completed Segment.

ChannelType,Address,User.UserId

VOICE,<YOUR_PHONE_NUMBER>,<YOUR_USER_ID>

Figure 13. Sample voice segment.

Figure 13. Sample voice segment.

Uploading segments

1. Navigate to the Amazon Pinpoint console in the AWS Managenent Console.

2. Choose Manage Projects.

3. Select the Bus-Pinpoint-Project project that was created in the CloudFormation template.

4. From the left-hand menu, choose the Segments

5. Select Create a Segment.

6. Select Import a Segment and under Specifications select Upload files from your computer.

Figure 14. Options to select to import the segments created previously.

Figure 14. Options to select to import the segments created previously.

7. Select Choose files and upload the SMS and email segments you created in the previous section.

8. Choose Create a segment.

9. Once the segment is created, you can see it under the Segments tab in the Amazon Pinpoint project. Save the segment ID because you will use it to set up the variables in the Lambda function later.

Figure 15. Location of the segment ID, which will be used in later steps.

Figure 15. Location of the segment ID, which will be used in later steps.

10. Repeat Steps 5–8 for the voice segment. Save the segment ID for the voice segment as well.

Enabling email and SMS channels in Amazon Pinpoint

1. In the Amazon Pinpoint console, navigate back to the Bus-Pinpoint-Project. On the left-hand menu, choose the Settings

2. Under Email, select Manage.

3. Under Identity details, select Edit.

4. Select the check box under Enable the email channel for this project. For Identity type, select Email Address and Use an existing email address. Choose the email you verified in Amazon Pinpoint as the Default sender address. This will enable the email channel and allow you to send emails using the email address you verified earlier.

Figure 16. Sample for enabling the email channel.

Figure 16. Sample for enabling the email channel.

5. Repeat Steps 1–4 to enable the SMS channel as well. For Default message type, select Transactional since you are sending a time-sensitive alert.

Associating Lambdas and Amazon Lex bot

Next, run a Lambda function that associates the Amazon Lex bot and Lambda functions to our Amazon Connect instance.

1. In the CloudFormation template, go to Resources and select the link to the Lambda function that contains the name “LambdaAPI” under Logical ID.

2. Go to the Test tab and choose Create new test. Name it “Test-Lambda,” and leave the template as TestEvent. Select Save to save the test event.

Figure 17. Sample of the Lambda test event.

Figure 17. Sample of the Lambda test event.

3. Press Test to run the function. You should receive a message that says: “Execution result:succeeded.” The following image shows a successful test.

Figure 18. Successful execution result for the Lambda test event.

Figure 18. Successful execution result for the Lambda test event.

4. If you check the Contact Flows under your Connect instance, you should be able to see the Amazon Lex bot and Lambdas added into the instance. 

Updating Lambda Variables: LambdaPinpointSMSEmail

Next, we set up the Lambda functions to create the SMS or email and voice campaigns. These Lambda functions create campaigns in Amazon Pinpoint journeys and will send out the messages to the segments we created earlier.

1. In the Lambda function, go to the Configuration Select Environment variables from the menu on the left side.

Figure 19. Location of environment variables in the Lambda console.

Figure 19. Location of environment variables in the Lambda console.

2. Choose Edit.

3. Under the Value column, replace the text in SMSEmailSegmentId with the SMS or email Amazon Pinpoint segment ID that you copied earlier. Replace the EmailId with the email address you verified in Amazon Pinpoint. This is the email ID that Amazon Pinpoint will use to send the email message from.

Figure 20. Configuration of the environmental variables for the SMS and email segments Lambda function.

Figure 20. Configuration of the environmental variables for the SMS and email segments Lambda function.

4. Select Save.

Updating Lambda variables: LambdaPinpointOutboundCampaign

In the Lambda function, go to the Configuration Select Environment variables from the menu on the left side.

Figure 21. Location of environment variables in the Lambda console.

Figure 21. Location of environment variables in the Lambda console.

  1. Choose Edit.
  2. Under the Value column, delete the text in VoiceSegmentId and replace it with the voice segment ID that you copied earlier. Select Save.

Figure 22. Configuration of the environmental variables for the voice segment Lambda function.

Figure 22. Configuration of the environmental variables for the voice segment Lambda function.

  1. Select Save.

Updating contact flows

1. Log into your Amazon Connect instance. Under Contact flows, choose the “Bus-Delay-ContactFlow.”

2. On the left-hand side, choose the Get customer input.

Figure 23. Location of get customer input block in the Bus-Delay-ContactFlow.

Figure 23. Location of get customer input block in the Bus-Delay-ContactFlow.

3. Choose the Edu_Demo_Bot that you added to the instance. For the alias, choose LexBot-BusDemo-Alias and select Save.

Figure 24. Get Customer input block configuration.

Figure 24. Get Customer input block configuration.

4. Scroll to the right and choose the first Invoke AWS Lambda function.

Figure 25. Location oftfirst invoke AWS Lambda function block in the Bus-Delay-ContactFlow.

Figure 25. Location oftfirst invoke AWS Lambda function block in the Bus-Delay-ContactFlow.

5. Under Select a function, choose the SMSEmail Lambda flow we just added. Start this function first so that the SMS and email arrive around the same time as the voice message.

Figure 26. First AWS Lambda function block configuration.

Figure 26. First AWS Lambda function block configuration.

6. Scroll to the right and choose the second Invoke AWS Lambda function.

Figure 27. Location of second invoke AWS Lambda function.

Figure 27. Location of second invoke AWS Lambda function.

7. Under Select a function, choose the OutboundCampaign Lambda flow you just added.

Figure 28. Second AWS Lambda function block configuration.

Figure 28. Second AWS Lambda function block configuration.

8. Go to the top right hand side of the Connect console, select Save.

9. Select Publish to publish the flow.

Phone number association

1. Go to the Phone numbers tab in the Amazon Connect console.

2. Select the phone number you want to associate with the inbound call flow.

3. Choose Bus-Delay-ContactFlow and select Save.

Figure 29. Phone number mapping with Bus-Delay-ContactFlow.

Figure 29. Phone number mapping with Bus-Delay-ContactFlow.

Testing the solution

1. Sign in to your Amazon Connect Instance using a role that has agent permissions. Open the Agent Contact Control Panel (CCP) and set the agent to Active. This will allow you to run the outbound campaigns.

2. Call the phone number.

3. After the bot greets you and asks how it can help you, say, “I want to report a bus delay.

4. Say “Yes” when the bot asks you to confirm you are reporting that the bus broke down.

5. When the bot asks for a bus number, give it a sample bus number. For now, any number can be used as a sample bus number.

6. At the end of the flow, the bot will confirm that the delay has been reported. The Amazon Pinpoint journey will launch, and you will receive the SMS, email, and voice messages shortly after.

7. If the Flow is unable to launch the Outbound Campaigns, check to make sure all permissions are correct for the Campaigns to be launched through API.

Clean up

To remove the resources created by the stack, perform the following:

1. In the CloudFormation console, delete the CloudFormation template we launched in step 2.

2. In the Amazon Lex console, remove all Amazon Lex bots and Lambdas associated with the Amazon Connect instance.

3. Delete the Amazon Connect contact flow using the Amazon Connect Contact flow delete API.

Conclusion

Creating automatic communications solutions with AWS services like Amaozn Connect and Amazon Pinpoint can help improve school communication with parents. This walkthrough shows how bus drivers can report bus breakdowns and delays and send outbound communication to parents’ preferred channels using AWS services. To learn more about customizing Amazon Pinpoint journeys, refer to Building Your First Journey in Amazon Pinpoint.

Read related blog posts on the AWS Public Sector Blog:

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.

Swati Sharma

Swati Sharma

Swati Sharma is a solutions architect at Amazon Web Services (AWS) based out of Atlanta, Georgia. She has worked with contact center customers and is passionate about enabling customers in the cloud through code samples and projects.

Ankur Taunk

Ankur Taunk

Ankur Taunk is a specialist solutions architect at AWS supporting public sector customers. He works with public sectors customers to better understand their business, technical challenges, and how to achieve their desired business outcomes in the contact center space leveraging Amazon Connect.

Donald Rich

Donald Rich

Donald Rich is a solutions architect at Amazon Web Services (AWS) on the Amazon Connect customer acceleration team. He helps customer achieve their desired business outcomes in the contact center space leveraging Amazon Connect.