Skip to Content
Product Information

Memory Management in SAP Conversational AI

The aim of this blog post  is to give insights on the memory management tools provided in the SAP Conversational AI. Memory is required to store the Key values or Entities detected in the bot while the user is conversing with bot.

Using the memory variables, any chat with the user can be made more interactive by replying with personalized messages with usernames, preferences of the user or Business information extracted based on the data provided by the user.

The two memory objects which can be used in the SAP conversational AI are “memory” and “nlp”.

NLP stands for Natural Language Processing which contains details like what user typed, entities, intents identified from user expression at that time and other standard bot parameters. This object changes every time with message unlike memory which is persistent throughout the chat unless updated or reset.

Memory is an empty object at the starting of a conversation. Memory can be set or updated in three ways.

  1. Can be filled by using requirements tab under Build of a skill in the Bot builder.
  2. Can be Set or Unset using UPDATE CONVERSATION->EDIT MEMORY configuration under Actions tab of a skill in the Bot builder. Using this option entire memory object can be reset.
  3. Can be updated through API code in the web-hook call. One value of a memory or entire memory object can be set or reset using this method as the default body received by web-hook call contains Memory object.

The Values contained in both the objects can be accessed as {{memory}} and {{nlp}}. Let us have a deeper look into these scenarios.

1.Using Requirements tab under Build:

The values which can be set in the memory under requirements tab are Golden Entities, Custom Entities and intent details. The entities are the key values which are extracted from an expression in a conversation and used for further processing. Some standard entities like Temperature, City, Number,Email etc. are automatically detected. These values can be stored in the memory and can be used later on for data processing.

Requirements tab is like gathering inputs from user. If the required entity can’t be extracted from the expression user typed the memory is not updated. We can ask the user for the entity we are looking for.

We can think of a simple use case where a user wants to update email or check wallet balance. For validation of the user let’s suppose we need his phone number and Email id.

These are key values which are needed for validation and to retrieve user account details.

After the requirements are fulfilled we can see that memory is updated.

2.Using UPDATE CONVERSATION->EDIT MEMORY:

Memory object can also be updated using UPDATE CONVERSATION->EDIT MEMORY configuration under Actions tab of a skill in Bot builder. Here unlike former the values can be hard-coded or unset. Also the values stored in memory can be used as conditions for different messages.

Here we have copied the value of ‘email’ to a new variable ‘oldemail’, unset memory field ‘email’, and hard-coded another email-id into ‘newemail’ variable.

We can see that memory object is updated after the above operations.

Also the memory variables can be used to redirect to required skills dynamically. In our case both intents and skills are named same. So we can redirect the bot to required skill dynamically without selecting from drop-down.

We can use Memory object or nlp object in the conditions to trigger different actions and if else ladder can be simulated.

3.Using API call:

The default body received in the request by API via web-hook call contains entire memory object.

It can be updated in API and can be sent back to bot in response json .

Below screenshot that shows how memory can be updated in the API code and sent back to Bot.

In the API we have done following operations on the memory variable.

  • Unset variable user_intent and we haven’t changed the phone number.
  • Copied the newemail value into email variable , newemail and oldemail variables are removed from memory.
  • Set a new variable in API and assigned a value to it.

In the bot we can see that the changes done in the API code are reflecting.

In the end a few tips on how to use memory objects effectively.

  • When the trigger of two or more skills is based on a same memory value, the bot fails to trigger required skill and triggers fallback skill. So it is  better to set a memory field just like a flag before routing to required skill and use it in combination with the other memory value.
  • Entire expression typed by user can be accessed using {{nlp.source}}.
  • Sometimes it is not advisable to reset entire memory at the end of a task or action but till the time user wants to end chat. As user may want to perform different actions that the bot can do in a single conversation.
Be the first to leave a comment
You must be Logged on to comment or reply to a post.