Transcript

Transcripts record conversation events, including meta about the user, message and current module.

Transcripts are searchable, to provide context from conversation history with a given user, or based on any other attribute, such as listener ID.

Different instances can be configured to record an overview or drilled down analytics for a specific module’s interactions using its key.

Kind: global class


new Transcript(robot, [options], [key])

Param Type Description
robot Robot Hubot Robot instance
[options] Object Key/val options for config
[options.save] Object Store records in hubot brain
[options.events] array Event names to record
[options.responseAtts] array Response keys or paths to record
[options.instanceAtts] array Module instance keys or paths to record
[key] string Key name for this instance

Example (transcript to record room name when match emitted)

let matchRecordRooms = new Transcript(robot, {
  responseAtts: ['message.room']
  events: ['match']
})
// does not start recording until calling one of the record methods, like:
matchRecordRooms.recordAll()

transcript.recordEvent(event)

Record given event details in array, save to hubot brain if configured to.

Events emitted by Playbook always include module instance as first param.

This is only called internally on watched events after running recordAll, recordDialogue, recordScene or recordDirector

Kind: instance method of Transcript

Param Type Description
event string The event name
args… * Args passed with the event, usually consists of:
- Playbook module instance
- Hubot response object
- other additional (special context) arguments

transcript.recordAll()

Record events emitted by all Playbook modules and/or the robot itself (still only applies to configured event types).

Kind: instance method of Transcript


transcript.recordDialogue(dialogue)

Record events emitted by a given dialogue and it’s path/s.

Whenever a path is added to a dialogue, event handlers are added on the path for the configured events.

Kind: instance method of Transcript

Param Type Description
dialogue Dialogue The Dialogue instance

transcript.recordScene(scene)

Record events emitted by a given scene and any dialogue it enters, captures configured events from scene and its created dialogues and paths.

Kind: instance method of Transcript

Param Type Description
scene Scene The Scnee instance

transcript.recordDirector(director)

Record allow/deny events emitted by a given director. Ignores configured events because director has distinct events.

Kind: instance method of Transcript

Param Type Description
director Director The Director instance

transcript.findRecords(subsetMatch, [returnPath]) ⇒ array

Filter records matching a subset, e.g. user name or instance key.

Optionally return the whole record or values for a given key.

Kind: instance method of Transcript
Returns: array - Whole records or selected values found

Param Type Description
subsetMatch Object Key/s:value/s to match (accepts path key)
[returnPath] string Key or path within record to return

Example

transcript.findRecords({
  message: { user: { name: 'jon' } }
})
// returns array of recorded event objects

transcript.findRecords({
  message: { user: { name: 'jon' } }
}, 'message.text')
// returns array of message text attribute from recroded events

transcript.findKeyMatches(instanceKey, [userId], [captureGroup]) ⇒ array

Alias for findRecords for just response match attributes with a given instance key, useful for simple lookups of information provided by users within a specific conversation.

Kind: instance method of Transcript
Returns: array - Contains full match or just capture group

Param Type Description
instanceKey string Recorded instance key to lookup
[userId] string Filter results by a user ID
[captureGroup] integer Filter match by regex capture group subset

Example (find answers from a specific dialogue path)

const transcript = new Transcript(robot)
robot.hear(/color/, (res) => {
  let favColor = new Dialogue(res, 'fav-color')
  transcript.recordDialogue(favColor)
  favColor.addPath([
    [ /my favorite color is (.*)/, 'duly noted' ]
  ])
  favColor.receive(res)
})
robot.respond(/what is my favorite color/, (res) => {
  let colorMatches = transcript.findKeyMatches('fav-color', 1)
  # ^ word we're looking for from capture group is at index: 1
  if (colorMatches.length) {
    res.reply(`I remember, it's ${ colorMatches.pop() }`)
  } else {
    res.reply("I don't know!?")
  }
})