Example AWS Lambda function with a data action
The following content includes an example AWS Lambda function and a data action that executes the function.
- Download this .zip file: Example Lambda Project.
The .zip file contains the following items:
- Sample code (.js) to use in your Node.js 12.x Lambda in AWS.
- A sample data action (.json).
- In your AWS account, follow these steps:
- Create an AWS Lambda function with sample code (.js).
For more information, see Create a Lambda Function with the Console in the AWS documentation.
- Create a role that invokes the new Lambda function.
For more information, see Create IAM resources to invoke an AWS Lambda function.
- Make a note of the AWS Lambda ARN.
You will use this information in step 3c to update the Request URL Template for the data action, which calls the function. For more information, see Add configuration to custom actions for integrations.
- Create an AWS Lambda function with sample code (.js).
- In Genesys Cloud, follow these steps:
- Create an AWS Lambda data actions integration.
For more information, see Add a data actions integration.
- Import the data action (.json) into your AWS Lambda data actions integration.
This data action uses two inputs. One input is sent inside the body of the Lambda invocation. The other is sent as a header, which appears in the Lambda context. For more information, see Import or export a data action for integrations.
- Update requestUrlTemplate >with the ARN of your AWS Lambda function.
- Test your action using test mode.
If everything is configured correctly, a hello message echoing back your inputs appears. For more information, see Test data actions for integrations.
- Create an AWS Lambda data actions integration.
For more information, see About the AWS Lambda data actions integration.