Naming Prosecution Mitigator

    hubot-dynamic-conversation

    1.0.1 • Public • Published

    Hubot-dynamic-conversation

    This package helps you to make dynamic conversations with hubot. It allows you to collect information from a user based on some model questions

    Usage

    NB

    Currently, the v0.1.4 of the hubot-rocketchat does not properly support attachment. To add the attachment support use my fork of the hubot-rocketchat.

    Change the version number of hubot-rocketchat in your package.json to: https://github.com/ngenerio/hubot-rocketchat#a86a49244b87a73596fbc05f311e5d5c85737fa1 or use https://github.com/RocketChat/hubot-rocketchat/commit/72bbf02d519b5dedb2b8e45e093fe2b0b23df9b3

    Check the example.coffee for more information.

    DynamicConversation = require 'hubot-dynamic-conversation'
    dynamic = new DynamicConversation robot
     
    robot.respond /problem/i(msg) ->
      robot.logger.info 'hello'
      msg.reply "OK, I can make a maintenance report for you, just answer some questions..."
      maintenanceRequestModel = {
        abortKeyword: 'quit',
        onAbortMessage: 'You cancelled the conversation.',
        onCompleteMessage: 'Thanks for reporting this. I\'ll notify @bm immediately.',
        conversation: [ 
          {
            question: "Is it in a [public]or [private]area?",
            answer: {
              type: "choice",
              options: [
                {
                  match: "public",
                  valid: true,
                  response: "OK you said *public*, next step...",
                  value: "public"
                },
                {
                  match: "private",
                  valid: false,
                  response: "Sorry, you will have to find a contractor for private maintenance"
                }
              ]
            },
            required: true,
            error: "Sorry, I didn't understand your response. Please say [private] or [public] to proceed."
          },
          {
            question: "Please describe the issue.",
            answer: {
              type: "text"
            },
            required: true,
            error: "Sorry your response didn't contain any text, please describe the issue."
          },
          {
            question: "Please attach a photo of the issue if you have one."
            answer: {
              type: "attachment"
            },
            required: false,
            error: "Sorry the message didn't contain an attachment, please try again."
          }
        ]
      }
     
    dialog = dynamic.start msgmaintenanceRequestModel(err, msg, dialog) ->
      if err
        robot.logger.error err
      else
        data = dialog.fetch()
        robot.logger.info data
    # dialog is an instance of an EventEmitter 
    # It emits an `end` event when the dialog with the user is done 

    Install

    npm i hubot-dynamic-conversation

    DownloadsWeekly Downloads

    11

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • garychapman
    • ngenerio
    • timkinnane