Building a Slackbot 09: The Home Stretch

I was super productive this morning and actually got a lot of things working with oombaw.

First thing I had to do was setup the @oombaw export command. With botkit, that’s a pretty easy code to do. Just

controller.hears([‘export’], ‘direct_message,direct_mention’, (bot, message) => {

to start it off. Afterwards, setting up some basic interactive questions was relatively easy, I just had to make sure the timing of each subsequent function made sense.

After having a mechanism to ask for the vocab list, I had to build out my function that would handle the request. Nothing too complicated here. Just a search into the database and sending back what the user requested. Initially I thought I had to stringify the object, but I forgot that mongoDB is already JSON so I used json2csv to handle the request in the other function.

So after my bot gets back the object, json2csv converts it to a csv file and then I write it to my public folder using


. Pairing that with a


function using




to handle cleaning up my files after 3 minutes and my bot is good to go.

Check it out!

Next up is cleaning up my code a bit, abstracting some things out that get repetitive, and probably implementing a save preference and a help command. I think I’ll be essentially done after that!