Skip to content

Commit

Permalink
init dialog doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfcabral committed Mar 20, 2024
1 parent a53804b commit 1a15320
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/dialogs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Dialogs

Botgen system for multi-turn conversations builds upon BotBuilder's dialog system, offering a range of powerful features such as persistent conversation state, typed prompts with validation, and other advanced functionalities. Now, all these capabilities can be seamlessly integrated with Botgen!

Dialogs serve as predefined "maps" for conversations, capable of being triggered in various ways. Consider a dialog as the script for an interactive conversation that the bot can navigate, potentially branching based on user input. Dialogs can include conditional tests, branching patterns, and dynamic content. You can create dialogs using Botgen's intuitive syntax or BotBuilder's WaterfallDialogs.

To utilize a dialog, it must first be defined and added to the bot's dialog stack. Below is an example demonstrating the use of BotgenConversation dialog type.

## Basic usage

In this basic usage you can define a onboarding dialog every time someone join the chat.

```python
from botgen import Bot
from botgen.adapters import WebAdapter
from botgen import BotWorker
from botgen import BotMessage
from botgen import BotConversation

adapter = WebAdapter()
bot = Bot(adapter=adapter)

dialog = BotConversation(dialog_id="onboarding", controller=bot)

dialog.say("Hello!")
dialog.say("This is the botgen onboarding")

bot.add_dialog(dialog=dialog)

async def onboarding_dialog(bot_worker: BotWorker, message: BotMessage):
await bot_worker.begin_dialog("onboarding")

bot.on("channel_join", onboarding_dialog)
bot.start()

```

0 comments on commit 1a15320

Please sign in to comment.