Introduction
Context memory
every conversation in kindly has its own key value store named context that serves as the bot's memory for that conversation saving values the bot can collect information from the user via pattern dialogues docid\ gvajtawi0kmo rzzksbqj in addition, if the bot sends a webhooks reference docid\ ot0nvuq i76ze m5vrvuc to another service, the response from the webhook service can contain new context as well keep in mind that the context memory is a simple key value storage if you insert a key value pair where the key already exists in the memory, the value will be overwritten and the old value will be lost retrieving values when defining bot replies, you may insert placeholders that look like {key} if key is found in the chat context, the value will be inserted if key is not available, the bot will not use that reply, but try to find something else to reply with, or go to a fallback reply the full context is also sent with every webhooks reference docid\ ot0nvuq i76ze m5vrvuc , allowing you to perform any operation you'd like on the context data in your own service managing context via api if you're using application api docid\ cgad bxmm1 wvggzsmd1k , you can also read and write to the context storage with your api requests writing to context when you send data, you can send new context which will be merged with any existing context for the chat if you send a key value pair where the key already exists, the value will be overwritten if the key does not exist the key value pair will be inserted (upsert strategy) example curl \\ h 'content type application/json' \\ h "authorization your api key" \\ d '{"user id" "unique user id", "message" "hello world!", "new context" {"key" "value"}}' \\ https //bot kindly ai/api/v1/send reading context when you receive a message from the bot, you will also find the context is attached as part of the json payload example { "message" "hello world!", "context" { "key" "value" } } set context in kindly chat in some cases you might want to add data to the chat context on kindly chat initialization, for instance to know on which page the chat client is loaded or the email of a logged in user you can set chat context when initializing the chat client by populating window\ kindlyoptions context before loading the kindly chat html snippet read more about the available options on the chat widget api docid\ vegid5rt7yj6qjx71w2ly