> For the complete documentation index, see [llms.txt](https://docs.launchboard.app/cxd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.launchboard.app/cxd/code-chatbot-1/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.launchboard.app/cxd/code-chatbot-1/code-mods/adding-topics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
