https://github.com/suttna/botbuilder-command-line
Easy creation of command line tools for your BotBuilder bot.
https://github.com/suttna/botbuilder-command-line
botbuilder command-line nodejs typescript
Last synced: 12 days ago
JSON representation
Easy creation of command line tools for your BotBuilder bot.
- Host: GitHub
- URL: https://github.com/suttna/botbuilder-command-line
- Owner: suttna
- License: mit
- Created: 2017-09-06T22:25:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-13T11:04:00.000Z (about 1 month ago)
- Last Synced: 2025-05-07T20:02:04.293Z (12 days ago)
- Topics: botbuilder, command-line, nodejs, typescript
- Language: TypeScript
- Homepage: https://suttna.com
- Size: 134 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

# botbuilder-command-line [](https://badge.fury.io/js/botbuilder-command-line) [](https://circleci.com/gh/suttna/botbuilder-command-line)
botbuilder-command-line makes really easy the creation of command line tools for your BotBuilder bot.
Features:
- Nice DSL for creating command line dialogs
- Arguments and options parsing
- Configurable authentication for command## Install
```
yarn add botbuilder-command-line
```> This library was only tested in Slack. It should work in other channels too.
## Usage
```javascript
const { UniversalBot } = require('botbuilder')
const { CommandLineLibrary } = require('botbuilder-command-line')const bot = new UniversalBot(connector)
const lib = new CommandLineLibrary("operations", {
isAuthorized: async (user) => {
return user.id === process.env.SUPER_USER_ID
},
})lib.command("list-active-dialogs", {
description: "List the active dialogs",
handler: async (session, context) => {
const activeDialogs = await DialogRepository.activeDialog()session.endDialog(formatDialogList(activeDialogs))
},
})lib.command("destroy-dialog", {
description: "Destroy the given dialog.",
options: [
{
name: "id",
description: "The dialog identifier",
required: true,
},
],
handler: async (session, context) => {
await DialogRepository.destroy(context.options.id)session.endDialog('I have destroy your dialog')
}
})bot.library(lib)
```We have created a new CommandLineLibrary with the name operations. `operations` will be the name to use when invoking a command. The `operations` CommandLineLibrary will only be triggered if a recognizer emits the `operations` intent. This means you will need to create a custom recognizer in your bot and emit the `operations` intent yourself.
This will look like this probably:
```javascript
bot.recognize({
recognize: (context, done) => {
if (context.message.text.startsWith('operations')) {
done(null, { score: 1.0, intent: 'operations' })
} else {
done(null, { score: 0.0 })
}
}
})
```> We are going to move this logic inside the library to make the library experience more friendly.
After adding the previous recognizer you can now invoke the command like this:
```
operations list-active-dialogsor
operations destroy-dialog --id 10
```
## Todo- [ ] Implement recognizer inside library
- [ ] Add boolean flags## Contact
- Martín Ferández
- Santiago Doldán