Playbook

Playbook brings conversational context and branching to Hubot.

Modules are available as properties and their instances as collection items.

Uses singleton pattern to make sure only one Playbook is created when used in multiple script files loaded by the same Hubot.

Kind: global class


playbook.use(robot, [improvise]) ⇒ Playbook

Attach Playbook to robot unless already done.

Kind: instance method of Playbook
Returns: Playbook - Self for chaining

Param Type Default Description
robot Robot Hubot instance
[improvise] boolean true Enable/disable improv module and middleware (default true)

playbook.dialogue(res, […args]) ⇒ Dialogue

Create stand-alone dialogue (not within scene).

Kind: instance method of Playbook
Returns: Dialogue - New Dialogue instance

Param Type Description
res Response Hubot Response object
[…args] * Optional other Dialogue constructor args

playbook.scene([…args]) ⇒ Scene

Create new Scene.

Kind: instance method of Playbook
Returns: Scene - New Scene instance

Param Type Description
[…args] * Optional Scene constructor args

playbook.sceneEnter(res, […args], [cb]) ⇒ Promise

Create and enter Scene.

Kind: instance method of Playbook
Returns: Promise - Resolves with final enter middleware context

Param Type Description
res Response Response object from entering participant
[…args] * Both Scene and Dialogue constructor args
[cb] function Called with context after enter middleware done

playbook.sceneListen(type, regex, […args], callback) ⇒ Scene

Create scene and setup listener to enter.

Kind: instance method of Playbook
Returns: Scene - New Scene instance

Param Type Description
type string Robot listener type: hear respond
regex RegExp Match pattern
[…args] * Scene constructor args
callback function Callback to fire after entered

playbook.sceneHear([…args])

Alias of sceneListen with hear as specified type.

Kind: instance method of Playbook

Param Type Description
[…args] * Scene constructor args

playbook.sceneRespond([…args])

Alias of sceneListen with respond as specified type.

Kind: instance method of Playbook

Param Type Description
[…args] * Scene constructor args

playbook.director([…args]) ⇒ Director

Create new Director.

Kind: instance method of Playbook
Returns: Director - New Director instance

Param Type Description
[…args] * Director constructor args

playbook.transcript([…args]) ⇒ Transcript

Create a transcript with optional config to record events from modules

Kind: instance method of Playbook
Returns: Transcript - The new transcript

Param Type Description
[…args] * Transcript constructor args

playbook.transcribe(instance, […args]) ⇒ Transcript

Create transcript and record a given module in one step.

Kind: instance method of Playbook
Returns: Transcript - The new transcript

Param Type Description
instance * A Playbook module (dialogue, scene or director)
[…args] * Constructor args

playbook.improvise([options]) ⇒ Improv

Initialise Improv singleton module, or update configuration if exists.

Access methods via Playbook.improv property.

Kind: instance method of Playbook
Returns: Improv - Improv interface

Param Type Description
[options] Object Key/val options for config

playbook.shutdown()

Exit all scenes, end all dialogues.

Kind: instance method of Playbook


playbook.reset() ⇒ Playbook

Shutdown and re-initialise instance (mostly for tests).

Kind: instance method of Playbook
Returns: Playbook - - The reset instance


playbook.outline([…args]) ⇒ Playbook

Load outline and setup scene listeners for global bits.

Kind: instance method of Playbook
Returns: Playbook - The reset instance

Param Type Description
[…args] * Additional outline constructor args