0

i am trying to call lambda in module and want some data in main caller flow. is there is a way to access data or does module return anything back to flow.. example will be helpful

example will be helpful or piece of code

1 Answer 1

0

To pass input parameters to a contact flow module, call a Lambda function within the module, and then retrieve output parameters back in the main contact flow in Amazon Connect, you can follow these steps:

Create and Configure the Lambda Function:

Ensure your Lambda function is set up to accept input parameters, process the data, and return the required output parameters in the response.

exports.handler = async (event) => {
    const customerId = event.Details.Parameters.customerId;
    
    // Your processing logic here
    
    const response = {
        customerName: "John Doe",
        accountBalance: "150.00"
    };
    
    return response;
};

Create the Contact Flow Module:

Define Input Parameters:

Open the Amazon Connect console. Go to Routing > Contact Flow Modules and create a new module. Use the Set contact attributes block to define input parameters like customerId. Invoke the Lambda Function:

Add the Invoke AWS Lambda function block. Configure it to call the Lambda function created earlier. Map the input parameters to the Lambda function.

Function ARN: arn:aws:lambda:region:account-id:function:function-name

Input parameters:
    {
       "Details": {
           "Parameters": {
               "customerId": "$.Attributes.customerId"
           }
       }
    }

Set Output Parameters:

After the Lambda invocation, use the Set contact attributes block to capture the Lambda function's response and define output attributes.

Name: customerName
Value: $.External.customerName

Name: accountBalance
Value: $.External.accountBalance

Invoke the Contact Flow Module in the Main Contact Flow:

Set Input Parameters:

In the main contact flow, before calling the module, use the Set contact attributes block to set the required input parameters.

Name: customerId
Value: $.Attributes.customerId

Invoke the Contact Flow Module:

Use the Invoke module block to call the contact flow module you created. This module will receive the input parameters, call the Lambda function, and set the output parameters. Retrieve Output Parameters:

After the Invoke module block, use the Check contact attributes block to access the output parameters set by the module.

Check for attribute: customerName
Value: $.Attributes.customerName

Check for attribute: accountBalance
Value: $.Attributes.accountBalance

Example Contact Flow Configuration Here is a high-level outline of the steps involved in both the contact flow module and the main contact flow:

Contact Flow Module:

Set contact attributes:

Input: customerId from $.Attributes.customerId Invoke AWS Lambda function:

Function ARN: arn:aws:lambda:region:account-id:function:function-name Input parameters: {"Details": {"Parameters": {"customerId": "$.Attributes.customerId"}}} Set contact attributes:

Output: customerName from $.External.customerName Output: accountBalance from $.External.accountBalance Main Contact Flow:

Set contact attributes:

Input: customerId to $.Attributes.customerId Invoke module:

Module: Your contact flow module Check contact attributes:

Output: customerName from $.Attributes.customerName Output: accountBalance from $.Attributes.accountBalance By following these steps, you can effectively pass input parameters to a contact flow module, call a Lambda function within that module, and retrieve the output parameters back in the main contact flow in Amazon Connect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.