# hubot-dynamic-conversation

> Have conversation with user without the hustle of `robot.hear`

Latest version **1.0.1** (published 2016-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install hubot-dynamic-conversation
pnpm add hubot-dynamic-conversation
yarn add hubot-dynamic-conversation
bun add hubot-dynamic-conversation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-07-26 |
| First published | 2016-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eugene Asiedu |
| Maintainers | garychapman, ngenerio, timkinnane |
| Keywords | hubot, dynamic, conversation, dialog, forking, bot, robot |

## Links

- npm: https://www.npmjs.com/package/hubot-dynamic-conversation
- npm.io page: https://npm.io/package/hubot-dynamic-conversation

## Dependencies (2)

- [async-series](https://npm.io/package/async-series.md) 0.0.1
- [hubot-conversation](https://npm.io/package/hubot-conversation.md) ^1.1.1

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-07-26
- 1.0.0 — 2016-07-26

## README

# 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](https://github.com/RocketChat/hubot-rocketchat) does not properly support attachment. To add the attachment support use my fork of the [hubot-rocketchat](https://github.com/ngenerio/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](https://github.com/4thParty/hubot-dynamic-conversation/blob/master/example.coffee) for more information.

```coffee
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 msg, maintenanceRequestModel, (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
```

---
_Source: https://npm.io/package/hubot-dynamic-conversation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
