Menu

Expand
Rate this page:

Remember

The Remember action allows you to add values to an Assistant's memory. It takes key-value pairs and stores them in the memory object of the Dialogue payload to be returned in subsequent requests.

With the Remember action, you can store key information that is persisted across intents to build rich dialogs such as shopping carts, order flows or any multi-step task.

Make sure to see how to use a Memory value in a user's response using say.

Static example: Remember a customer's first name

{
	"actions": [
		{
			"remember": {
				"first_name": "Valentina"
			}
		}
	]
}

The values are then stored in the Assistant's memory. All the data in the memory will be sent in the Memory parameter as either POST parameter or URL query parameter, depending on which HTTP method you've configured.

{
   "first_name": "Valentina"
}

Dynamic example: Redirect to a Twilio Function to remember different variables based on user input. This way, the Actions JSON is rendered dynamically.

{
    "actions": [
        {
            "redirect": "https://replace-with-your-function.twil.io/dynamicremember"
        }
    ]
}

In a Twilio Function, the following code adds new variables called "status" and "order" to your bot's memory to indicate where the conversation ended when it is handed off to an agent. Autopilot provides the current memory of the bot as a JSON object in each request it makes to your application.

exports.handler = function(context, event, callback) {
    console.log(Object.keys(event));
    let memory = event.Memory;
    let respObj = {};
    console.log("Memory "+memory);
    let msg = "Thank you for providing customer information! I'm now transferring you to an agent to finish the order.";
    respObj = {
        "actions": [
            {
                "say": msg
            },{
                "remember": {
                    "status": "complete order",
                    "order": memory
                }
            }
	]
    };
    callback(null, respObj);
};

Overwriting behavior

A given key-value pair is overwritten when it is remembered again. If a new key is provided it will be added to the map.

When executing exactly the same collect flow twice or more times the values will be overwritten in the memory.

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more