Coder Social home page Coder Social logo

suttna / botbuilder-command-line Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 136 KB

Easy creation of command line tools for your BotBuilder bot.

Home Page: https://suttna.com

License: MIT License

TypeScript 96.22% Shell 3.78%
botbuilder command-line nodejs typescript

botbuilder-command-line's Introduction

https://suttna.com

botbuilder-command-line npm version CircleCI

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

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:

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-dialogs

or

operations destroy-dialog --id 10

Todo

  • Implement recognizer inside library
  • Add boolean flags

Contact

botbuilder-command-line's People

Contributors

bilby91 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

botbuilder-command-line's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency minimist to v1.2.8
  • Update dependency botbuilder to v3.30.0
  • Update dependency @types/node to v20
  • Update dependency tslint to v6
  • Update dependency typescript to v5
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • botbuilder ^3.9.0
  • minimist ^1.2.0
  • @types/jest 22.1.0
  • @types/node 8.9.4
  • @types/minimist 1.2.0
  • jest 22.1.4
  • bot-tester 3.4.2
  • ts-jest 22.0.2
  • ts-node 4.1.0
  • tslint 5.9.1
  • typescript 2.7.2

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.