> For the complete documentation index, see [llms.txt](https://docs.idew.org/code-chatbot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idew.org/code-chatbot/code-mods/adding-topics.md).

# Using Topics

There are a couple of ways you could add topics to your chatbot. But we recommend you do it the following way if you are working in teams.

Remember that you can always access the [reference material for RiveScript](https://www.rivescript.com/docs/tutorial#topics) to understand them more.&#x20;

**1. Create separate chatbot script files for each topic.** In addition to your main script file (*bot.rive*) create files like *bot-topic-1.rive* and *bot-topic-2.rive* for your topics.

&#x20;**2. Place topic tags in each of the new files** with the script embedded like this.

```
  > topic 1
    + start
    - Greetings from topic 1.

    + (hello|hi)[*]
    - Hi, you are in topic 1.

    + bye
    - {topic=random} OK. I'll send you back to the main script.{@ start}

  < topic
```

**3. Include an entry point to the new topics** in your main chatbot script file using something like this, where the bot goes to the new topic if the visitor types "go to topic 1".

```
   + go to topic 1
   - {topic=1} {@ start}
```

The `{@ start}` triggers the new topic's `+ start` line. So in this case the chatbot would respond to "go to topic 1" with "Greetings from topic 1".

**4. Lastly, have the javascript load your new files.** Find the `chatbot.loadFiles` function in your `code.js` file and add your new files like below.

```
chatbot.loadFiles(['bot.rive', 'bot-topic-1.rive', 'bot-topic-2.rive']);
```

> You will definitely want to customize and refine the scripts above, but you should be on your way.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.idew.org/code-chatbot/code-mods/adding-topics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
