The simplest way to set up snarkov is using Heroku. Just press this button to deploy it:
You'll need to set up a Slack outgoing webhook to send messages to snarkov. Set it up so it listens to a single channel of your choice, don't set up a keyword. Copy the integration's token, you'll need it to deploy the app. You'll also need a Slack API token. You can get one by going to this page while logged into Slack. Once you have everything in place, deploy the app, then set the outgoing webhook's url to
https://[your-heroku-app].herokuapp.com/markov, and save it.
Snarkov works better if it has a lot of text to work with. To help populate it, you can feed it the entire history of a list of Slack channels. Warning: Depending on how many messages are in the channel's history, this might take a long time, and potentially fill up your free Heroku Redis account very quickly. You'll probably want to go to your Heroku dashboard and upgrade your Redis plan to one of the paid levels before doing this, or use the
DAYS option to limit the amount of text you're importing.
To populate redis in production, install the Heroku Toolbelt and run:
$ heroku run rake ingest CHANNELS='#channel-name' --app your-heroku-app-name
ingest task takes a single channel name, or a comma-separated list of channel names, e.g.:
$ heroku run rake ingest CHANNELS='#random,#general' --app your-heroku-app-name
If you want to import a channel's history going back only a certain number of days, you can add a
DAYS option. For example:
$ heroku run rake ingest CHANNELS='#random,#general' DAYS=5 --app your-heroku-app-name
This will import the last 5 days of chat history from the #random and #general channels.
If you only want to import a certain user's messages, use the
USERNAME option. For example:
$ heroku run rake ingest CHANNELS='#random,#general' USERNAME="guille" --app your-heroku-app-name
After snarkov is up and running, the outgoing webhook you set up will send every message in the channel you selected (except those from other integrations) to snarkov, which will process and store it for future usage. It might respond with a Markov-generated message of its own, depending on the number you have set in the
RESPONSE_CHANCE environment variable, with 0 meaning it will never respond, and 1 meaning it'll respond every single time.
If you have a Mac, a fun thing to do is run this in the terminal:
$ curl -s http://[your-heroku-app]/markov?token=[outgoing-webhook-token] | say -i
.envfile and put the config variables there (see
foreman start -f Procfile.dev
http://localhost:5000/markovto populate it, with the
textparameter being the message's text, and
tokenthe outgoing webhook's token.
http://localhost:5000/markov?token=[OUTGOING_WEBHOOK_TOKEN]to see a random reply
git checkout -b my-new-feature)
git commit -am 'Added some feature')
git push origin my-new-feature)
Copyright (c) 2014, Guillermo Esteves All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.