Context Store

In this tutorial you will learn about the Context Store Node, what it does and how to use and its Settings

1. What it does

Context Store node provide a way to store/persist key or value data into conversation state as well as persistent storage like DB.

2. How to use

Place this node where ever you need to get, set or update or delete some key.

Example, you can use Context Store node to persist the Food order items and Quantities of the order for particular user, such that to utilize the data at successive conversations with that user.
When you use Context as Conversation to set some variable, always connect the Respond Node, next to the Context store Node, in order to persist data before responding to user.
Example:


Above will set the FoodItem and Quantity, in the Conversation context.
Similarly, to get the FoodItem and Quantity, you need to use the Command as Get

3. Node Setting

  • Name
    Name for Node
  • Context
    Defines three ways to persist data.
    • Conversation level(Recommended):
      The data stored here will be persisted throughout the conversations with user, till the session ends. Once the sesssion ends, all the conversation data will be lost.
      Note: For Alexa this conversation context is like state attributes.

      When you select Context as Conversation, then data will only be persists till:
      • You end the session for that particular conversation, OR
      • You set the Request User Input as No in Respond Node for that particular conversation.

    • Group Conversation level:
      Store data related to conversation into this context when multiple users taking part in conversation i.e. group chat. In this data is stored in DB wrt to combination of userId and conversationId. The data persists throughout the lifetime of application whether session ends or not.
    • User level:
      Store data related to user into this context type. In this, data is stored in DB wrt to userId only. The data persists throughout the lifetime of application whether session ends or not.
  • Command
    Defines three ways to manipulate or update data. GET, SET and DELETE.
  • Key
    Name of key to store
  • Value
    Value to be stored corresponding to particular key.
    Value can be any thing like string, number, boolean, JSON or can be taken from other variables like msg., flow. and global.

4. Input

Context Store Node takes input from any node.

5. Output

Context Store Node modifies the msg.govocal.conversationContext, or msg.govocal.groupConversationContext or msg.govocal.userContext and passes the msg object to next connected node.

Example:

msg.govocal = {
    …
    “conversationContext”: {
        “FoodItem”: “Pizza”,
        “Quantity”: “3”
    },
    “groupConversationContext”: {
        …
    },
    “userContext”: {
       …
    },
    …
};

Note: Only for Context as Conversation, you can manually modify the msg.govocal.conversationContext, but need to do before sending the response to user via Respond Node