Working with Bot Memory

Bot memory contains data about your users and all their conversations. Learn how to use and update it in the Cognitive Flow.

Types of memory

Short-term memory

This is where all the information from the current conversation with the user is stored. It is updated during each conversation but you can also modify it.

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. Each channel has it’s own way of identifying users. For the Web, Mobile and Rest channels this ID is coming from the chat.user.id configuration value
  • 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, confirmation, webhook, or set-entity command.

Question and confirmation steps will gather the input from the user in a conversation, webhook step will store the result of a web service call as an entity in the bot memory, and set-entity command will set a value specified in the cognitive flow.

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

External data

During a conversation, you can make requests to 3rd-party systems to retrieve or send data. Check the Working with external data article for use cases and usage descriptions.