Multi-Channel Tone Analysis in PHP with Amazon Comprehend

Published July 02, 2020 by Adam Culp

In this post, you’ll update an AWS Lambda function introduced in a previous post where the results of a voice transcription get stored in RDS. The objective for this example is to use Amazon Comprehend to retrieve the tone analysis for an entire conversation, by channels, and then add the results to an RDS MySQL database instance.

See nexmo-community/voice-channels-aws-transcribe-php, and nexmo-community/aws-voice-transcription-rds-callback-php for an understanding of what you will be working with for this example.

Prerequisites

Setup Instructions

With the nexmo-community/aws-voice-transcription-rds-callback-php code deployed, you will need to update the index.php file in the following ways:

  • Add an import statement for AWS Comprehend, to the top of the file with the other imports.

  • From line 54 to 62, update the $conn-insert() contents to include the sentiment field.

  • Add the following function to the end of the file, that enables sentiment to get populated for the database insertion.

  • Update the conversations table in the RDS database created in the previous post, to include the sentiment content.

Deploy to Lambda

With all the above updated successfully, you can now use Serverless to redeploy the app to AWS Lambda.

Ready

Your app is now updated to include tone analysis with the conversation content, going forward.

Next Steps

If you have any questions or run into troubles, you can reach out to @VonageDev on Twitter or inquire in the Nexmo Community Slack team. Good luck.

Leave a Reply

Your email address will not be published.

Get the latest posts from Nexmo’s next-generation communications blog delivered to your inbox.

By signing up to our communications blog, you accept our privacy policy , which sets out how we use your data and the rights you have in respect of your data. You can opt out of receiving our updates by clicking the unsubscribe link in the email or by emailing us at [email protected].