See related
No related articles

Amazon Connect: Integrate Kustomer data into your IVR using Lambdas

Last Update: Oct 2024 • Est. Read Time: 4 MIN
To check plan availability, see the pricing page.

You can use Kustomer data in your Amazon Connect IVR contact flows to dynamically insert customer data, conversation data, and custom object data (for example, order information) inside your contact flows. There are many ways this could be valuable for automation, but here are a few examples:

  • When a customer calls in, use their phone number to automatically look up a custom attribute, such as "medallion status", in Kustomer and branch them to a special queue based on the value.
  • Automatically tell a customer the current status of their most recent custom object (e.g. shipping status of an order, or status of a flight).
  • Check to see if they have an existing open conversation in Kustomer, and if so, append the call to an existing omnichannel conversation, rather than create a new conversation.
Who can access this feature?
User typesAll users with permissions to access Insight Cards.


In this article:

Install Kustomer Lambda Functions using CloudFormation

Before you get started, make sure you have already set up Kustomer and Amazon Connect independently. You will also need to be logged into your AWS console, and have permission to install CloudFormation templates.

  1. Use the AWS CloudFormation console to create a new stack and enter the following in the Template URL box: https://s3.amazonaws.com/kustomer-prod1-connect-lambda/kustomer.template
  2. In another browser tab, navigate to your Kustomer account and go to Settings > Security > API Keys.
  3. Select Add API Key and create a new key with the following properties:
    • Name: Amazon Connect Lambda API Key
    • Roles: org.user.read
    • Expires (in days): No Expiration
  4. Select Create, copy the API key, and store it in a secure location.

    Note: You will not have another opportunity to copy the key again once you close the window.

  5. Take the copied key value and navigate back to the AWS Create Stack page from Step 1. 
  6. Paste this value in the API key field. Finally, select the acknowledgment box, and select Create.
  7. After the creation is complete, you should now have three new Lambda functions. These three functions allow you to look up a customer's:
    • Record in Kustomer using their phone number.
    • Last conversation using their customer ID. 
    • Last custom object using their customer ID and a Klass Name.

Use Lambda functions in Amazon Connect contact flows

To access your Kustomer data in your contact flows (IVRs) you need to use the Lambda functions that were just created. Before you do this, you should have a basic understanding of Amazon Connect contact flows.

  1. From your Amazon Connect account, go to the Contact Flows settings page in the Routing section. From here you can create a new contact flow or edit an existing contact flow. 
  2. From the contact flow editor, create a new Invoke AWS Lambda function step by dragging it from the Integrate section of the left sidebar into the workspace.
  3. In this first example, we're going to use a lambda function to look up the customer by their phone number by using the KustomerGetCustomer lambda function we installed in the past section. To do this we'll need to get the Amazon Resource Name (ARN) of that lambda function. To get the ARN of any Lambda function in AWS, go to your Lambda settings, select the Lambda function, and copy the ARN value from the top right. Paste this into the function ARN input inside of the Amazon Connect contact flow.
  4. Directly following your newly-created Invoke AWS Lambda Function step, you'll want to add some handling to check if the Lambda successfully returned data. To do this, make a new Check contact attributes step, and verify that an id value was returned from the Lambda using the following settings:
  5. If the value is unknown you'll want to link that step to some sort of error handling. However, if the no match condition is met, a customer object was returned by the Lambda function. From here, you should store the customer's ID as a contact attribute in case you want to look up more customer information later. Create a new Set contact attribute step with the following settings:
  6. From here, you can use any of the attributes returned by the Lambda function in this contact flow. Here are some example customer attributes you can reference. For example, if you wanted to play a prompt to the customer that included their account data, you could do so using the Text To Speech setting in the Play Prompt step.
  7. To use the other two Lambda functions (KustomerGetKobjectFunction and KustomerGetConversationFunction) you'll need to pass along the function input parameters. The KustomerGetConversationFunction only needs the customerId contact attribute that was previously defined in step 5. However, to look up a KObject, you'll need to pass along a Klass attribute to specify which KObject class you're looking up:

    Here are some examples of Conversation Data and KObject data that are returned from the Lambda functions. Please note however that your data will always be different depending on your data in Kustomer.

Test and push data live

After you save and publish your contact flow, you need to connect the flow to a test phone number in your account. To do this, go to the Routing section on the left navigation sidebar, and select Phone Numbers. Pick a phone number that you want to connect this contact flow to (either a test or live number). After selecting the phone number, change the Contact Flow / IVR used to your newly created Contact Flow:

Before you call and test this contact flow, make sure there is a customer record in your Kustomer account that is connected to the phone number you're going to call from. The IVR will look up the customers by the value in the Phone Numbers record. Make sure this customer has at least one conversation or custom object on their timeline if you plan to use the KustomerGetConversationFunction or the KustomerGetKobjectFunction: