# 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: 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.idew.org/code-chatbot/code-mods/adding-topics.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.
