So I'm trying to execute a Lambda function based on the value of a contact attribute (checked by a Check Contact Attributes clock) that I set on the previous contact flow. My question is, are the contact attributes local to the contact flow or can they be referenced from the next contact flow? Right now it's not working for me, when I check the contact attribute value it never matches with the value that is supposed to have been set (I check this after setting it in the previous contact flow).
Also getting this from the Lambda function that is checking the value (existingCase is the name of the Contact Attribute):
'existingCase': KeyError Traceback (most recent call last): File "/var/task/lambda_function.py", line 11, in lambda_handler print("Is it existing case " + event["Details"]["ContactData"]["Attributes"]["existingCase"]) KeyError: 'existingCase'
Thanks!
Contact Attributes are specific to a call/contact. An attribute that is set in one contact follow can’t be accessed by another Contact Flow. Likewise, attributes are no longer available to a Contact Flow after the call/contact ends (even if it is the same calling party).
If you need the attributes to be available to subsequent contacts from the same customer endpoint, you would need to call a lambda function and store the attributes in an external data store, like DynamoDB, using the customer’s phone number (or some other identifier specific to the customer/caller) as the key. In the beginning of your Contact Flow, you could invoke another lambda function that searches dynamo using the customer endpoint (customer’s phone number) and restores the attributes from the previous contact using the data in dynamo. This effectively scopes the contact attributes to the customer, rather than the contact.
NOTE: this is just an example to illustrate the scope of the attributes and should not be used in a production scenario, as many caller may be seen as having the same endpoint (phone number).