Skip to main content
Skip table of contents

What is $context?

In Coworkers.ai, a $context is the bot’s internal memory — a set of named variables used to store and manage information during a conversation.

Each conversation stores its own $contexts and you can explore them in the Discussions/Calls detail:

context.png

What gets stored in $context?

$context values are created automatically or manually and are updated throughout the conversation. They include:

System contexts

  • Discussion metadata (stored with $sys_ prefix, e.g., start time, system state, etc.)

User contexts

  • API responses — your mapped values (e.g., delivery status, user account info) + system info (e.g., response status)

  • Manually set values (e.g., $user_verified = "true" from a Context module or a Lambda (code block) module in the dialog flow

  • Dialog flow modules — values from modules that try to detect, understand, and store particular pieces of information (e.g., the Entities module, the Form module, Numbers extraction, Name extraction, etc.).

    • Each module describes the $context values it sets in its settings panel when you click on it.

image-20250707-120120.png

Example of $context values set by Name extraction module

To manually set, edit, delete, increment, decrement, or copy a value to another context key, use the Context module in the dialog flow.

Where can $context be used?

$context values can be used anywhere in your dialog flow to steer your dialog flow logic, personalize answers, or drive decisions.

1. In Conditions

Use context values to route the conversation:

  • Check if a value exists or not, and react accordingly

  • Compare numbers, strings, booleans, or two $context values

image-20250707-120817.png

This Condition module triggers the “Premium Customer” path if the $api_client_type context value = vip, and the “Others” path in all other cases.

2. In Bot Replies

Insert dynamic data into text replies, buttons, or speech:

image-20250707-121404.png

This Message module will display the actual stored values of the contexts, so, e.g., “Hello Ms. Coworky! How can I help you?”

3. In most Module settings inputs

Use $context inside:

  • Prompts in the AI Knowledge or other LLM modules

  • Button actions, links, redirect URLs, etc.

image-20250707-121852.png

4. In Lambda (a custom code block - JavaScript)

Access and manipulate all $context values freely in the Lambda module.

Note: All $context values are stored in the context object, so must be prefixed with context..

CODE
return {
  $full_name: context.$first_name + " " + context.$last_name
}

All context values are stored as strings.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.