Skip to content

Commit

Permalink
Merge pull request #129 from codigoencasa/master
Browse files Browse the repository at this point in the history
docs: self-interaction
  • Loading branch information
leifermendez authored Aug 28, 2024
2 parents efac849 + 13c2753 commit 2de5c76
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pages/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sections = [
This is a __free__ and open source framework with an intuitive and extensible way to create chatbot and smart apps that connect to different communication channels like __[Whatsapp](/plugins/telegram)__, __[Telegram](/plugins/telegram)__ and others.
We have made an intuitive framework so you can have your first chatbot in minutes.

[![BuilderBot Framework](assets/awards.webp)](https://a.cstmapp.com/voteme/974264/712365893)
<a href="https://a.cstmapp.com/voteme/974264/712365893" target="_blank"><img src="assets/awards.webp" alt="BuilderBot Framework" class="rounded-lg" /></a>


## Quick Start
Expand Down
32 changes: 32 additions & 0 deletions src/pages/en/uses-cases/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,38 @@ const flow = addKeyword<BaileysProvider>('botoff')

---

## Bot Self-Interaction {{ tag: 'state' }}

In certain scenarios, it is necessary for the bot's phone number (host) to be able to interact within logical flows. To achieve this, we have several configurable options:
- **host:** This is used when you want the bot to be able to respond to messages in the same chat with itself. For example, if the bot's number is 0000, it will be able to send and receive messages to/from 0000.
- **both:** This option allows both the bot and you (the developer/administrator) to intervene in the chat of a person interacting with the bot.
- **none:** (default option) Only allows interaction between the user and the bot, without intervention from the host number.

```ts {{ title: 'app.ts' }}
import { createBot, createProvider, createFlow, addKeyword, MemoryDB } from '@builderbot/bot'
import { BaileysProvider } from '@builderbot/provider-baileys'

const main = async () => {
const adapterDB = new MemoryDB()
const adapterFlow = createFlow([...])
const adapterProvider = createProvider(BaileysProvider, {
writeMyself: 'host' as 'none' | 'host' | 'both'
})

adapterProvider.initHttpServer(3000)

await createBot({
flow: adapterFlow,
provider: adapterProvider,
database: adapterDB,
})
}

main()
```

---

<Guides />

<Resources />
Expand Down

0 comments on commit 2de5c76

Please sign in to comment.