> For the complete documentation index, see [llms.txt](https://atlas.anywhere.now/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atlas.anywhere.now/product-reference/dialogue-studio/dialogue-studio-example-flows/simple-chatbot.md).

# Simple chatbot

Import a starter multi-channel chatbot flow for Dialogue Studio that greets customers, tracks conversation stage, and routes keyword-matched requests to an agent.

This example builds a basic text chatbot. It greets the customer, waits for a reply, and routes the conversation using keyword matching. Use it as a starting point for a self-service chat flow that always leaves the customer a way to reach an agent.

## What it does

The flow routes incoming sessions by channel, greets new conversations, and then checks the customer's next message against a small set of keywords (agent, website, FAQ, goodbye). Anything it does not recognize is routed to an agent rather than left unanswered.

## Prerequisites

* A UCC configured with Dialogue Studio and a pre-queue or bot-enabled text channel.
* A skill or queue (`flowid`) that the enqueue nodes can hand off to. The imported flow uses a placeholder flow ID (`1234`) on every enqueue node.

## Preview

![Simple chatbot flow](https://2627137428-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FscZpnEdBjDgQmlVn1iLr%2Fuploads%2Fgit-blob-6e4608d711d9411fa8bdbc697fb0263b11d720bf%2Fsimple-chatbot.png?alt=media)

## Import the flow

1. Log in to your Dialogue Studio environment.
2. Open or create a tab for the flow.
3. From the menu in the top right, select **Import** and add the JSON from [`flows/simple-chatbot.json`](https://github.com/AnywhereNow/atlas-docs/tree/main/product-reference/dialogue-studio/dialogue-studio-example-flows/flows/simple-chatbot.json).
4. Deploy the flow.

## Configure after import

* Update the `flowid` value on every **enqueue** node to match the skill or queue you want the conversation handed off to.
* Review the greeting and keyword-response text and adjust it for your own service.
* The example's documentation response links to the public Atlas home page. Replace it with your own customer-facing help destination before using the bot for your service.
* The comment node "ToDo add API Key" is a placeholder reminder in the source flow. This example does not call an external API, so no key is required here; if you extend the flow to call one, follow your organization's approved secret handling and never paste a real key into an exported flow.

## How the flow works

* An **incoming-message** node receives every new message and passes it to a **Switch** node that checks `payload.channelId`:
  * Channel `0` (Email) is enqueued directly and is not routed to the bot.
  * Channels `1` (SMS), `3` (WhatsApp), `4` (Web Chat), and `5` (Generic) are all routed to the bot logic.
* A second **Switch** node checks `payload.flowId` to track which stage of the conversation the customer is in:
  * `null` means this is the first message. The bot greets the customer and waits for a reply (`wait-for-message` with `flowid` set to `1`).
  * `1` means the customer already received the greeting and is replying to it.
  * Any other value is treated as unexpected and falls through to the same keyword check as stage `1`.
* A **Switch** node with regular expressions checks the customer's reply for keywords:
  * `talk` or `agent` responds that an agent will be connected, then enqueues the conversation.
  * `website` or `site` shares a link to the AnywhereNow website, then waits for another message.
  * `question` or `faq` shares a link to the documentation home page, then waits for another message.
  * `bye` (case-insensitive) thanks the customer and disconnects the session.
  * Anything else tells the customer their message was not understood and routes them to an agent, so the conversation never gets stuck.
* A **debug** node captures the full incoming message for troubleshooting.

## Safe fallback behavior

Every branch that does not match a known keyword enqueues the customer to an agent instead of looping or dropping the message. The source flow's own comments call this out explicitly: "Always make an escape so the customer doesn't get stuck."

## Verification

1. Send a message on a supported channel (SMS, WhatsApp, web chat, or generic) and confirm the greeting is sent.
2. Confirm a message on the Email channel is enqueued directly, without the bot greeting.
3. Reply with a keyword such as "agent" and confirm the conversation is enqueued.
4. Reply with "website" or "faq" and confirm the correct link is sent, then the flow waits for another message.
5. Reply with "bye" and confirm the session disconnects.
6. Reply with an unrecognized message and confirm the customer is still routed to an agent rather than left without a response.

## Related topics

Go to [Dialogue Studio example flows](/product-reference/dialogue-studio/dialogue-studio-example-flows.md) for the full gallery of example flows.


---

# 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://atlas.anywhere.now/product-reference/dialogue-studio/dialogue-studio-example-flows/simple-chatbot.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.
