2

I have created a entity called #USER-NAME and have set that as a requirement.

Now, for the first time when the entity is detected in the conversation - say, "I am John" , then the memory is set to John. On subsequent encounter of the same entity with different value - "I am Dave", the memory remains unchanged.

I have seen the edit memory option, which provides 1. reset memory 2. set to a value . For the option 2, it does not provide a way to set to the value of #USER-NAME, instead only provides option to enter static values.

How can I update the memory every time the value of the entity changes ??

EDIT

Hi, I am attaching some screenshots to show what's exactly going wrong.

  1. I have a Entity named '#USER_NAME' that saves the user name in a memory variable .

  2. I make the following conversation - Conversation

  3. The JSON payload after the conversation is as follows. This works perfectly- Response1

  4. I update the conversation again by providing a new user name. Conversation 2

  5. This triggers the entity just fine. You can see the entity being detected properly. Entity

  6. However, the memory value remains the same. memory

What I wanted was the memory variable to replace 'Dev' with 'John'.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Boudhayan Dev
  • 970
  • 4
  • 14
  • 42

2 Answers2

1

the memory is a persistent object so if you want to reset it you need either to have specific conditions within the builder or go through a webhook to have a backend code to reste the memory.

plieb
  • 1,130
  • 1
  • 9
  • 23
  • So, everytime the entity is triggered, I am suppose to make a webhook call to my API endpoints, which will replace the existing memory variable to the new value ? This doesn't look like a good solution. Anyway, I have updated the question with more details. – Boudhayan Dev Jan 24 '19 at 05:13
  • You don’t need to call a webhook you can actually set dynamically an entity value in the memory such as: MY_VARIABLE = {{nlp.entities.MY_ENTITY[0].value}} see documentation here https://cai.tools.sap/docs/concepts/builder_messages under variables – plieb Jan 24 '19 at 05:18
  • This only updates the display. Memory object will still retain the earlier value. What you linked is for displaying data from the JSON object model at the backend. It doesn't talk about how to modify that JSON object model itself – Boudhayan Dev Jan 24 '19 at 06:39
  • You can update the memory object with the variable. What you need to do is: 1) have a requirement with alias_1 2) set a variable_2 that will contain the memory value alias_1 and reset alias_1 that way every time you have a new value you reset it. Currently that is the only way as there is no builder built in logic to set a variable as “rewritable” – plieb Jan 24 '19 at 06:50
  • Is it too much if i ask for some screenshots ? I tried what you mentioned but couldn't get it to work. – Boudhayan Dev Jan 24 '19 at 06:56
  • 1
    I’ll try to better detail and send the screenshots later :) in your skill add a requirement let’s say email with the alias **email** - when it’s missing send a text saying “What’s your email?” and in Actions you need to 1) Update the memory with a new variable named **email_saved** with the value (between quotes) “{{memory.email.raw}}” and then 2) in a new edit memory block reset the memory value of **email** now what you have is only one field in your memory which is **email_saved** which contains your email value and you should be able to rewrite the email - hope that is clearer :) – plieb Jan 24 '19 at 07:54
1

Remember that:

memory <> Intent

You can set memory in the message section or update automatically using for example a requirement in this case every time the skill is trigged it will replace the value in the memory ID

EDIT: Because the set memory field expect a JSON you can't use memory as you want, but if you reset that memory ID shomewhere relevant in the chat (in my sample I delete it right after saying Hi XXX) so when the skill is trigged again it will "replace" it with the new value

In the Requirement I set the golden entity #Person to variable "name" and if is missing I ask her name.

Sample Image

RAMGV
  • 26
  • 3
  • I do not want to replace using the requirement method. As it only allows me to set a static value Ex - abc. The value that I want to set is going to be provided by the user when the entity is triggered. So, it can be abc, xyz or anything else. Currently, I don't see an option to set dynamic value for the memory fields. Something like, Memory field = {{entity.value}} . This isn't permitted. Anyway, I have updated my question. Please take a look to see what I mean. – Boudhayan Dev Jan 24 '19 at 05:11
  • Okay this is really simple and great. It works. Thanks – Boudhayan Dev Jan 25 '19 at 03:20