How to retrieve items stored with the Remember function in Twilio

Viewed 514

I am creating a chat bot with Twilio Autopilot that asks for personal information in the beginning and I would like to much later in the chat give back that information back to verify.

According to the Twilio docs the Remember action can be used to store a key-value pair to be returned later. I am, however, unable to find any documentation on how to retrieve the data stored later.

I have attempted to use the event.Memory.[keyName] in a function as well as

memory.twilio.collected_data.[keyName]
2 Answers

Twilio developer evangelist here.

It's memory.twilio.collected_data.[taskName].answers.[keyName].answer.

Your taskName is set in the Collect Action which may look something like this in the JSON task bin:

{
    "actions": [
        {
            "collect": {
                "name": [taskName],
                "questions": [
...

Then, the keyName would be set in the next few lines right below:

                    {
                        "question": {
                            "say": "We're sorry we can't chat with you right now to help. What's your first name?"
                        },
                        "name": [keyName],
                        "type": "Twilio.FIRST_NAME"
                    },
...

Things saved with the remember action get put at the top level of the memory object.

You can pull it out with the following:

JSON.parse(event.Memory)[keyName]
Related