cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to merge memory in webhook with new properties?

Former Member

Hi,

if I send this to the chatbot:

{"conversation":{"memory":{"username":"bob"}}}

it will replace the actual memory.

I tried this but it didnt work.

{"conversation":{"memory":{"username":"bob"},"merge_memory":true}}

is it possible to merge only with the API? Or is this also possible in the webhook?

Best regards

Philipp

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member757943
Discoverer
0 Kudos

Hi Philipp,

Yes it is possible to merge the memory in webhooks. There is no option to keep the current memory and add new key/values, the right way to do it is to get the current memory of the conversation that is sent in the request, and add the key/value pairs you want to have in your memory.

For example:

You can access the memory of the request like so:

existing_memory = request.body.conversation.memory

When sending the response, you can merge the existing memory with something else, in Javascript it would look like:

{conversation: {memory: {...existing_memory, ...{username: "bob"}}}}

With this, the memory will not be overwritten.

Best regards

Hugo