Skip to content

Instantly share code, notes, and snippets.

@kevinmarx
Last active December 22, 2015 01:59
Show Gist options
  • Save kevinmarx/6400542 to your computer and use it in GitHub Desktop.
Save kevinmarx/6400542 to your computer and use it in GitHub Desktop.
I am giving a talk at the local Node user group on building a life embetterment robot. This is my current outline.

How To Train Your Robot

Not that kind of robot

This kind of robot

What is this robot you speak of?

Enter: Hubot

What is Hubot?

  • Hew-bot
  • A Customizable, Kegorator-Powered Life Embetterment Robot
  • Written in Node.js and Coffeescript
  • Uses Redis to persit data in its "Robot Brain"

What is Coffeescript?

  • The Devil
  • CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
  • Written By Jeremy Ashkenas
  • Compiles to vanilla Javascript, with no interpretation at runtime

So what do you use Hubot for?

  • Originally as a chat bot and to automate running tests etc.
  • Generating memes
  • General time-wasting

How do you use Hubot?

Adapters

  • connects Hubot to the outside world

Syntax sugar that is coffeescript

Scripts

  • Repo managed by github
  • stuff the robot actually does

Script

  • Two ways .respond and .hear, respond requires a prompt (primary way)
  • send the message out

But wait there's more!

  • I started thinking about how limiting pre-built life-embetterment robots were
  • Hubot is command driven, Siri and Google I have little control over their tasks
  • What if I could merge the two?

Enter: Natural Language Processing

  • I started looking into how I could get Hubot to understand me more naturally
  • My wife's a Master of English so I began asking her to re-teach me english syntax
  • How do I get the computer to understand English?
  • Tokenizing, trying to find relevant words etc.
  • Started building my own language processor...really, really hard.

To the Googles! Da na na na na na

  • Started looking for open source natural language processors for node.js
  • Not nearly as roboust as I wanted

What I found

  • Stanford Language Processor
    • Java App
    • Had node run it in a sub shell and pass it stuff
    • Really slow
    • Returns garbage, so I needed to create an adapter to conver to JSON

Still not what I wanted

Enter: Elastic Search

  • Combined with the HTML Web Speech API
  • I could now just send the entire string and get weighted results

So How'd you do it

  • Well naturally I named my robot Jarvis
  • And naturally I wanted him to speak in a British accent

Enter: ElasticSearch

  • I could now just send plain english to my database and get weighted results
  • results will have a string that will match one of the hubot scripts regex, low manipulation of hubot core.

Enter: i18next

  • Run all of the robot's responses through tranlsation
  • Sectioning out the parts of speech
  • Localizing responses to time of day and randomizing similar response phrases

What Does It Look Like?

  • SQLite
  • Elastic Search
  • Rails
  • Node (Hubot)
  • XMPP

Why Rails

  • I looked at node options for elastic search apis and found that for speed of development and general niceness the Tire gem was great.
  • Good Practice

The Gift of Speech

  • Hijack Apple's speech files to get a cool British accent
  • Have node execute say commands in a sub shell to get the robot talking
Spike: Language is inherently synchronous, Node is not
  • The robot was talking over himself
  • Quick touch on the async library and managing control flows with node
  • Show stupid binding in coffeescript

Nitty Gritty

  • XMPP adapter for Hubot for use with a web interface
  • Jarvis talks to his "Brain" which is a SQLite with a rails server on top
  • uses XMPP
  • Why Rails? Because the Tire gem is amazeballs
  • The "brain" responds with an "executable" object which node will then parse the json and execute the function contained in the object.
  • Still uses is lesser Redis brain for simple things

What's next?

  • I would like to build a more robust web interface for him so that he can respond with visuals as well as audio and text

Quick Demo

@kevinmarx
Copy link
Author

I suppose I should touch on writing scripts for Hubot

@chrisarcand
Copy link

Yeah scripts would be good.

Forseeable questions, putting on the user hat:

  1. What's a Redis? Is it actually red?
  2. So what exactly is i18next? Something to do with translation, you say?
  3. Diagram outlining the workflow of the bot ('Nitty Gritty' in a picture rather than just bullet points)?

Also, for presenting, I really dig the Reveal.js that @mrDarcyMurphy used for his presentation last week http://lab.hakim.se/reveal-js/#/

Gonna be schweeeeeet.

I can't believe your hubot's name isn't german.

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