> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Management

<Badge icon="arrow-left" color="gray">[Back to NLP Topics](/ai-for-service/automation/natural-language/nlp-topics)</Badge>

Context management lets AI Agents carry information from one intent to the next, enabling natural, human-like conversations. Without it, the AI Agent would re-ask for information the user already provided.

**Example:**

> **User:** What is the cost of an Economy flight from London to Paris on Aug 15?
> **AI Agent:** It's €242.
> **User:** Great! I'd like to book it.

The AI Agent should already know the flight details from the previous intent — no need to ask again.

***

## Use Cases

| Scenario                                    | Description                                                                                                                                                                                                          |
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sharing context across intents and FAQs** | Context is maintained across dialog tasks and FAQs, enabling a consistent experience.                                                                                                                                |
| **Context-driven FAQs**                     | A FAQ is available only when a specific intent is already in context. For example, *What meal options are available?* shows only when *Book a Flight* is active.                                                     |
| **Follow-up intent detection**              | The current context helps identify the next intent. For example, *What are the extra charges?* resolves to *What are the charges for a Premium Economy seat?* if the user just asked about Premium Economy benefits. |
| **Sharing entity values**                   | Entity values from one intent pre-populate entities in another. For example, *Destination City* from *Check Flight Status* pre-fills *City Name* in *Check Weather*.                                                 |

## Implementation

Context management involves four steps:

1. **Output Context** — Define tags that mark the current intent as executed.
2. **Intent Preconditions** — Use output context tags to scope which intents are detected next.
3. **Contextual Intent Detection** — Use context tags to identify relevant intents and FAQ paths.
4. **Conversation Flows** — Customize flows using context tags to pre-populate entities or define transitions.

***

### Output Context

**Context Tags** are generated and stored in the context object. The Platform creates a context object for every user intent (dialog tasks and FAQs). [Learn more](/ai-for-service/automation/agent-flows#context-object)

**Default context tags** — Intent names, entity names, and FAQ term/node names are emitted automatically.

**Custom context tags** — You can define additional tags for the following:

#### Dialog Tasks

* The intent name is emitted as a context tag when execution starts.
* Add extra tags from the **NLP Properties** tab of the dialog task.

<img src="https://mintcdn.com/koreai/Unx9yfFXBZX99ORY/ai-for-service/automation/intelligence/images/set-dialog-task.png?fit=max&auto=format&n=Unx9yfFXBZX99ORY&q=85&s=5e39a7869ca825b097f15a675c440cfe" alt="set dialog tasks" width="558" height="657" data-path="ai-for-service/automation/intelligence/images/set-dialog-task.png" />

* Emit tags from any JavaScript location (script node, advanced prompts, run-a-script) using `contextTags.add("value")`.

#### Alert Tasks

* The task name is emitted as a context tag when execution starts.
* Add extra tags under **More Options** or **General Settings**.

<img src="https://mintcdn.com/koreai/Unx9yfFXBZX99ORY/ai-for-service/automation/intelligence/images/set-alert-tasks.png?fit=max&auto=format&n=Unx9yfFXBZX99ORY&q=85&s=dab2ff0d50051907373e5de3d68069ee" alt="set alert tasks" width="1024" height="434" data-path="ai-for-service/automation/intelligence/images/set-alert-tasks.png" />

* Emit tags from pre-processors or post-processors using `contextTags.add("value")`.

#### Entities

* Entity values are emitted based on the **Auto emit the entity values captured** toggle.
* Add extra tags per entity node.

<img src="https://mintcdn.com/koreai/w09kb1UZUWzj6OHW/ai-for-service/automation/intelligence/images/add-entity-tag.png?fit=max&auto=format&n=w09kb1UZUWzj6OHW&q=85&s=cf074925eab40d8925de0a814f06554f" alt="add entity tags" width="550" height="664" data-path="ai-for-service/automation/intelligence/images/add-entity-tag.png" />

#### Knowledge Graph

* Node and term names are emitted as context tags for all mandatory and optional terms in a qualified path.
* Add extra tags per term from the term's **Settings** page.

<img src="https://mintcdn.com/koreai/w09kb1UZUWzj6OHW/ai-for-service/automation/intelligence/images/add-kg-tags.png?fit=max&auto=format&n=w09kb1UZUWzj6OHW&q=85&s=e34cda83931d97ad4c54244d1777d5cf" alt="add KG tags" width="1024" height="434" data-path="ai-for-service/automation/intelligence/images/add-kg-tags.png" />

* Emit tags from advanced prompts using `contextTags.add("value")`.

***

### Intent Preconditions

Intent preconditions define when an intent or FAQ becomes available for detection — only when specific context tags are present.

#### Dialog Tasks

* Add one or more preconditions to make a dialog intent available only in the right context.

<img src="https://mintcdn.com/koreai/w09kb1UZUWzj6OHW/ai-for-service/automation/intelligence/images/dialog-tasks-preconditions.png?fit=max&auto=format&n=w09kb1UZUWzj6OHW&q=85&s=dcc29f0be7d6c7440587b4f8e4db1d57" alt="dialog task preconditions" width="558" height="657" data-path="ai-for-service/automation/intelligence/images/dialog-tasks-preconditions.png" />

* Intents with preconditions are treated as sub-intents and follow [Linked Task Exception](/ai-for-service/automation/intelligence/sub-intents-and-follow-up-intents#linked-task-exceptions) behavior.

#### Alert Tasks

* Add one or more preconditions to make a task available only in the right context.

<img src="https://mintcdn.com/koreai/Unx9yfFXBZX99ORY/ai-for-service/automation/intelligence/images/input-preconditions.png?fit=max&auto=format&n=Unx9yfFXBZX99ORY&q=85&s=2898907be1d2c5223a312259f69ec6e8" alt="input preconditions" width="1922" height="815" data-path="ai-for-service/automation/intelligence/images/input-preconditions.png" />

#### Knowledge Graph

* Define preconditions per term in the Knowledge Graph.

<img src="https://mintcdn.com/koreai/w09kb1UZUWzj6OHW/ai-for-service/automation/intelligence/images/define-intent-preconditions.png?fit=max&auto=format&n=w09kb1UZUWzj6OHW&q=85&s=abca835b5f329cf84663c9aab7bb1ff4" alt="define intent preconditions" width="1024" height="434" data-path="ai-for-service/automation/intelligence/images/define-intent-preconditions.png" />

* A path is qualified only if its term preconditions are met.

***

### Contextual Intent Detection

#### Tasks

Define rules for contextually relevant intent detection using output context tags (similar to traits). [Learn more](/ai-for-service/automation/natural-language/training/traits)

#### Knowledge Graph

Enable context tags to qualify paths in the Knowledge Graph:

1. Go to **Build > Natural Language > NLU Config > Knowledge Graph**.
2. Set **Qualify Contextual Paths** to **Yes**.

<img src="https://mintcdn.com/koreai/Unx9yfFXBZX99ORY/ai-for-service/automation/intelligence/images/qualify-contextual-paths-window.png?fit=max&auto=format&n=Unx9yfFXBZX99ORY&q=85&s=41241cc513747a88ae05b8b6de165b60" alt="qualify contextual paths" width="1637" height="734" data-path="ai-for-service/automation/intelligence/images/qualify-contextual-paths-window.png" />

***

### Conversation Flows

Use context tags to customize dialog flows:

* Pre-populate entity values.
* Define transition conditions.
* Build custom conversation flows.

**Script references:**

| Context               | Script                         |
| --------------------- | ------------------------------ |
| Current context tags  | `context.currentTags.tags`     |
| Previous context tags | `context.historicTags[0].tags` |

***
