Search code examples
pythonamazon-web-servicesaws-lambdaamazon-connect

How to pass attributes from amazon connect in amazon lambda?


for example, in one contact flow, I set a contact attribute: Name: Jack Jackson

Then the contact flow is transferred to a second contact flow via caller's selection.

In the second contact flow, I wish to invoke a lambda function, where I want to be able to use the attribute "Name: Jack Jackson".

How should I make a reference to that variable?

I read the guide, and it says the following is a JSON request from connect to lambda, but I did not see any key-value pair referring to a set contact attribute.

Thanks in advance.

`The following is an example JSON request to a Lambda function:
{
 "Details": {
 "ContactData": {
 "Attributes": {},
 "Channel": "VOICE",
 "ContactId": "4a573372-1f28-4e26-b97b-XXXXXXXXXXX",
 "CustomerEndpoint": {
 "Address": "+1234567890",
 "Type": "TELEPHONE_NUMBER"
 },
 "InitialContactId": "4a573372-1f28-4e26-b97b-XXXXXXXXXXX",
 "InitiationMethod": "INBOUND | OUTBOUND | TRANSFER | CALLBACK",
 "InstanceARN": "arn:aws:connect:aws-region:1234567890:instance/
c8c0e68d-2200-4265-82c0-XXXXXXXXXX",
 "PreviousContactId": "4a573372-1f28-4e26-b97b-XXXXXXXXXX",
 "Queue": "QueueName",
 "SystemEndpoint": {
 "Address": "+1234567890",
 "Type": "TELEPHONE_NUMBER"
 }
 },
 "Parameters": {
 "sentAttributeKey": "sentAttributeValue"
 }
 },
 "Name": "ContactFlowEvent"
}`

Solution

  • All Contact Attributes set by Contact Flows will show up in the Details.ContactData.Attributes property of the request payload. In your example you would see

    "Details": {
        "ContactData": {
          "Attributes": {
            "Name": "Jack Jackson"
          }
    

    Using python (with handler function of def lambda_handler(event, context):, you would access the Name Contact Attribute using

    event["Details"]["ContactData"]["Attributes"]["Name"]