Skip to content

Instantly share code, notes, and snippets.

@abMatGit
Last active August 10, 2016 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abMatGit/5308e80aa9009c5bea1c79f24b9c422f to your computer and use it in GitHub Desktop.
Save abMatGit/5308e80aa9009c5bea1c79f24b9c422f to your computer and use it in GitHub Desktop.

Hubot

  • Flow of Input -> Output is managed via Adapters and Hubot's "core" robot functionality. Adapters are initialized with a Hubot instance. They forward messages directly to the robot instance. They are also responsible for building a reply back to the source.
  • Architecturally the Hubot (robot core) is aware of the adapter, and the adapter is aware of hubot.

Here's what a quick implementation looks like with SlackBot: https://github.com/slackhq/hubot-slack/blob/master/src/bot.coffee

create Hubot instance -> create adapter instance -> run

To view the sequence diagram, use jay's chrome extension

sequenceDiagram
    participant ChatSource
    participant Adapter
    participant Robot
    
    ChatSource->>Adapter: incoming message
    Adapter->>Adapter: parse the message
    Adapter->>Adapter: handle message type
    Adapter->>Robot: tell robot message has been received
    Robot->>Robot: uses heuristics to construct reply
    Robot->>Adapter: send replied message
    Adapter->>Adapter: wrap reply in ChatSource format
    Adapter->>ChatSource: send reply

-> parse the message

-> handle the message (these messages are abstracted in hubot here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment