AWS Lambda function callback script to be used by CloudWatch as a callback to store Voice Transcriptions to an RDS MySQL DB
- PHP 7.4 (update
serverless.ymlfor other versions) - Composer installed globally
- Node.js and npm
- Serverless Framework
- AWS account
- Vonage account
Clone this repo from GitHub, and navigate into the newly created directory to proceed.
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
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.
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=Install the serverless-dotenv-plugin with the following command.
npm i -D serverless-dotenv-pluginWith all the above updated successfully, you can now use Serverless to deploy the app to AWS Lambda.
serverless deployAfter 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 ruleto complete it.
Now you're ready to test.
The next time a Transcribe job finishes, this function will be ran.
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.