How to create a webhook listener in aws by using api and lambda?

  • Problem Statement:
    Log an incident in ServiceNow for all failure events triggered from Uipath Orchestrator. Send out notification emails to support team on every failure.

  • Solution:
    Create an API Gateway in AWS to listen to Orchestrator webhook events. And with help of Lambda, log an incident to ServiceNow. Use SNS within lambda to send out notification e-mail to support team.

  • Architecture Diagram:

Step-by-step guide:

  1. Create API Gateway service in AWS.

  2. Create a POST method for this API Gateway with integration type as “Lambda Function”.
    Create a new lambda function for python run.

  3. Under integration request of API, add new mapping template as below. This extracts the signature passed by Orchestrator in the request header and adds it to the request object for Lambda function

  4. Modify the lambda function as below:
    Import required packages in python


    Extract signature from the request and generate SHA256 hash from the raw request

    Compare the hash with the signature passed in the webhook event header. If both matches then extracts the required fields from request object and call SNS to send out notification and ServiceNow API to log an incident.

    Deploy the API. And in UiPath Orchestrator, add new webhook and use the deployed API’s URL and select individual events as per requirement

Source Code:
source.zip (1.7 KB)

References:

API Gateway Mapping Template: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

4 Likes

I am grateful for reading this post! Thanks for helping us in many ways!

1 Like