Skip to content

AWS Lambda function callback script to be used by CloudWatch as a callback to store Voice Transcriptions to an RDS MySQL DB

License

Notifications You must be signed in to change notification settings

nexmo-community/aws-voice-transcription-rds-callback-php

Repository files navigation

aws-voice-transcription-rds-callback-php

AWS Lambda function callback script to be used by CloudWatch as a callback to store Voice Transcriptions to an RDS MySQL DB

Prerequisites

Setup Instructions

Clone this repo from GitHub, and navigate into the newly created directory to proceed.

Use Composer to install dependencies

This example requires the use of Composer to install dependencies and set up the autoloader.

Assuming a Composer global installation. https://getcomposer.org/doc/00-intro.md#globally

composer install

AWS Setup

You will need to create AWS credentials as indicated by Serverless.

Also, create a new RDS Instance using the default settings. Make note of the ARN for later use. Use the /data/schema.sql contents to set up the database and table.

Update Environment

Rename the provided .env.default file to .env and update the values as needed from AWS.

AWS_VERSION=latest
AWS_REGION=us-east-1
AWS_VERSION=latest
AWS_RDS_URL=
AWS_RDS_DATABASE_NAME=
AWS_RDS_TABLE_NAME=
AWS_RDS_USER=
AWS_RDS_PASSWORD=

Serverless Plugin

Install the serverless-dotenv-plugin with the following command.

npm i -D serverless-dotenv-plugin

Deploy to Lambda

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

serverless deploy

Create Cloudwatch Trigger

After deploying this function, you can navigate to CloudWatch in your AWS Console and select Events and Get Started to create a new Event Rule.

Set the Rule as follows:

  • Event Pattern
  • Build event pattern to match events by service
  • Service Name = Transcribe
  • Event Type = Transcribe Job State Change
  • Specific status(es) = COMPLETED
  • As the Target select the Lambda function #2 created above
  • Scroll down and click Configure Details.
  • Give the rule a meaningful name and description, and enable it.
  • Click Create rule to complete it.

Now you're ready to test.

The next time a Transcribe job finishes, this function will be ran.

Contributing

We love questions, comments, issues - and especially pull requests. Either open an issue to talk to us, or reach us on twitter: https://twitter.com/VonageDev.

About

AWS Lambda function callback script to be used by CloudWatch as a callback to store Voice Transcriptions to an RDS MySQL DB

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages