Help creating a Hubot script for CATS?

42 views
Skip to first unread message

Jesse Hachey

unread,
Jun 19, 2015, 7:01:19 PM6/19/15
to cats...@googlegroups.com
Hi all! 

My company uses Slack, and we've recently set up a bot (Hubot) that can do a lot of tasks to make things easier for us. Our bot is named Hodor. :) 

The inspiration for this bot was the idea that we could perhaps use it to pull certain data from CATS about candidates and job orders. So examples of questions that could be asked: 

- What is [candidate name]'s phone number?
- What is [candidate name]'s email address?
- What is [candidate name]'s preferred salary?
- How many job orders are active for [Company Name]? 
- What is the salary range for [job order]? 
- What is the job description for [job order]?
- What is the web portal link for [job order]? 

I realize that some of these would be simpler than others ... and some might be impossible entirely. 

Hubot uses CoffeeScript, what appears to be a modified version of JavaScript. I've got very little coding experience but so far I've been able to put our bot together and enable it to do scripted tasks. 

Would anyone here have any insight into how I might accomplish these kinds of requests? I would be happy to provide as much information as necessary to help. 

Thanks! 

Jesse Hachey

unread,
Jun 19, 2015, 8:31:31 PM6/19/15
to cats...@googlegroups.com
So in doing further research, I determined that since CATS outputs all of its API into XML, and Hubot uses JSON, there's an "xml2json" plugin for Node that will allow you to translate one between the other: https://github.com/buglabs/node-xml2json

I'm very out of my depth here, but this is my script so far, designed to simply return a candidate name if queried (note that I do have my transaction code, it's just removed here): 

module.exports = (robot) ->
  robot.respond /Check CATS for (*)/i, (msg) ->
    msg
      .query
        subdomain: "huntex"
   transaction_code: ""
        keywords: msg.match[1]
        type: candidates
        is_email: ""
   max_results: 1
   offset: ""
 .get() (err, res, body) ->
   if num_results == "0"
 msg.send "I don't see a candidate in the system with that name."
else
 msg.send "I found a candidate named *{summary}* with ID# *{id}*."

Without xml2json, I don't think any of this will work.

Does anyone here have experience with node, JSON, and the rest? Could anyone comment on my code so far? Again ... very out of my depth, but I'm trying :) 

Thank you! 
Reply all
Reply to author
Forward
0 new messages