Working with Bot Memory

Bot memory contains data about your users and all their conversations. It is available to developers when building the Cognitive Flow.

Types of memory

Short-term memory

This is where all the information from the current conversation with the user is stored.

Long-term memory

After a conversation is completed, all the information from the short-term memory is saved in the long-term memory. And then the short-term is reset.

Information in the long-term memory can be used for displaying suggestions to the user or automatically pre-filling some of the data in a conversation.

User information

There is a built-in user entity that is always stored in your chatbot memory that contains information for the current user. You can access it like this:

{{user.FirstName}} {{user.LastName}}
  • FirstName, LastName: names of the user as extracted from the chat application
  • ExternalId: Id of the user as the chat application identifies him
  • Channel: Id of the bot’s Channel which this user is using to contact the bot
  • Avatar: URL for the user’s profile picture/avatar

System information

There is a built-in _system entity that is always stored in your chatbot memory and it contains system information:

{{_system.debug}}
{{_system.culture}}
{{_system.channel.ProviderName}}
{{_system.channel.IsProxy}}
  • debug: whether the session is in debug mode. A session in debug mode will display error messages in the chat. The session is always in debug mode when chatting through a proxy bot
  • culture: code of the culture of the chatbot (e.g. 'en' or 'bg'). Currently, the culture of the chatbot is inferred from its language and is not locale-specific
  • channel.ProviderName: the name of the provider of the channel. Examples: facebook, viber, darvin
  • channel.IsProxy: a boolean that is true when the conversation is going through a proxy channel

Storing data in bot memory

Entities can be stored in the short-term bot memory by running a step of type question, webhook or confirmation.

Question and confirmation steps will gather the input from the user in a conversation, while a webhook step will store the result of a web service call as an entity in the bot memory.

Displaying Entity Values

Each entity value stored in the short-term memory can be accessed by it’s name:

{{entityName}}

For example:

{{doctor}} is not available on {{date}}.

Will be displayed as: “Dr. John Burke is not available on 11 Feb.”

Formatting

Check how to format dates, numbers and other