# Context: topics and labels

AIsuru lets you create dynamic, context-aware conversations through the use of context. This feature lets you control when certain questions are appropriate and how the Agent should interpret and respond to user requests based on the conversation's context.

### Context: what it is and what it's for

Context management lets you define in which specific situations a question or response makes sense.

Context tells AIsuru what's being discussed at any given moment — which is necessary for guiding the conversation effectively, giving access to certain [contents](/en/agent-training/contents.md) while restricting visibility of others.

#### Topics and labels

Context in AIsuru is managed through two types of elements:

* **Topics** -> name-value pairs that define a specific context:

  * The name identifies the type of context (ANIMAL, OBJECT, etc.);
  * The value specifies the current context (DOG, SMARTPHONE, etc.).

  Example: ANIMAL:DOG
* **Labels** -> simple contexts:
  * The name identifies the subject being discussed (e.g., GENERAL\_QUESTIONS);
  * Labels are actually topics with "✔️" as a hidden value.

### Set context and required context

Topics and labels can be used in two different ways that affect how the Agent handles contents:

* **Set context** ("Set topics" in the platform):
  * Tells the Agent what's currently being discussed;
  * Helps the Agent prioritize the most relevant contents for the current context;
  * Does NOT restrict access to contents, but organizes them by relevance;
  * Example:
    * Question: "Let's talk about dogs";
    * Answer: "Sure, let's talk about dogs" \[set topic: `ANIMAL:DOG`];
    * After this, the Agent will know the conversation is about dogs and can give more relevant responses.
* **Required context** ("Required topics" in the platform):
  * Acts as a true filter that blocks the Agent from accessing certain contents until a specific context is set;
  * The AI can only access these contents WHEN that specific context is active;
  * If you don't set any required topics, the Agent will always have access to your content regardless of the current context;
  * Examples:
    * `ANIMAL:DOG`: the question is only relevant when talking about dogs;
    * `OBJECT:WAND`: the question is only appropriate in the context of a wand.

The key difference between the two types of context is:

* **Set context helps the Agent better understand the conversation** and prioritize the most relevant contents;
* **Required context completely blocks access to contents** until that specific context is set.

{% hint style="info" %} <mark style="color:blue;">Once a specific context is set, contents with that required context can also be passed to the generative AI to answer users' questions.</mark>
{% endhint %}

### How to manage context in your contents

#### Add a context

To add context to your contents:

1. Go to  **Contents** and create or edit an existing one;
2. Go to the "Advanced: context management" section;
3. Choose whether to add a set topic (under "Set topics") or a required one (under "Required topics");
4. Choose between "New topic" or "New label" based on your needs;
5. Fill in the name and value (if applicable) in the panel that opens;
6. Confirm and save the content.

💡 You can also use "Suggest labels" to get suggestions based on the content.

#### Cancel a context

To cancel a context, add a topic with the same name and **enter "-" as the value**.

Example: `ANIMAL:-` will cancel the "ANIMAL" context, which will no longer be set and will have no value.

### Practical examples

#### Scenario: assistant for a pet store

1. Agent asks the user: "What kind of animal are you interested in?";
2. User: "Dogs", set topic: `ANIMAL:DOG`;
3. Required topic: Question: "What are the specific dietary needs?", required topic: `ANIMAL:DOG`;
4. Canceling a context: Question: "I'd like to talk about a different animal", set topic: `ANIMAL:-`.

#### Conversation flow

1. User: "I'd like information about pets";
2. Agent: "Of course! What kind of animal are you interested in?";
3. User: "Dogs";
4. Agent: (sets `ANIMAL:DOG`) "Great! Dogs are wonderful animals. What would you like to know about dogs?";
5. User: "What are their dietary needs?";
6. Agent: (checks `ANIMAL:DOG`, question is relevant) "Dogs need a balanced diet. In general, they need high-quality proteins, carbohydrates, fats, vitamins, and minerals. The amount and type of food depends on the dog's age, size, and activity level...";
7. User: "I'd like to talk about a different animal";
8. Agent: (sets `ANIMAL:-`) "Of course! Which other animal would you like to talk about?".

{% hint style="info" %}
For security reasons, **the** [**generative AI**](/en/generative-ai.md) **cannot read or apply contexts on its own**. This is handled by AIsuru.
{% endhint %}

### Benefits of using context

* More natural and coherent conversations;
* More relevant and precise responses;
* The ability to create complex, branching dialogue paths;
* Better handling of multiple topics within the same conversation.

Effective use of contexts and context variables can turn your Agent into a truly intelligent, context-aware assistant. Experiment with these features to create rich, dynamic conversational experiences that adapt to your users' specific needs and interests.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aisuru.com/en/agent-training/advanced/content-customization/context-topics-and-labels.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
