Get Scamp for Campfire Running on Heroku

By Alex Holt - via

By Alex Holt - via

Scamp is a great bot framework for Campfire, and here's how to get a
bot up and running in no time on Heroku.

First up, create a new directory for the project and make sure
bundler and heroku gems are installed.

mkdir scampbot;cd scampbot
gem install bundler heroku

Then create a Gemfile

source :rubygems
gem 'rack'
gem 'scamp'

bundle, set up a git repo, and then create a new Heroku app

git init
git commit -a -m "boom"
heroku create

As Heroku is happy running Rack based apps, all we need to do here is include a rackup file named in the root directory.

#!/usr/bin/env ruby

require 'bundler/setup'
require 'rack'
require 'scamp'

# respond to something
run lambda { |env| [200, {'Content-Type'=>'text/plain'},'It's Alive!')] }

This tiny Rack app will just respond to any request with "It's Alive!" - handy for stopping Heroku apps sleeping on the job. Push it up to Heroku and try it out.

git add .
    git commit -m "Adding"
    git push heroku master
    heroku open

Next grab your Campfire API key - rather than checking this into the repo create some config vars instead

heroku config:add CAMPFIRE_KEY=your_api_key SUBDOMAIN=your_subdomain

With those variables in place start on Scamp

# do the robot
scamp =
  :api_key => ENV['CAMPFIRE_KEY'],
  :subdomain => ENV['SUBDOMAIN']

# add some rooms, can be ID numbers or room names
rooms = ['My awesome room', 1234 ]

Now the basics are in place all that's left to do is define some simple behaviour and connect to the rooms

scamp.behaviour do

  match /^blame (?<scapegoat>.+)$/ do
    say "Damnit #{scapegoat}!"


And that's it, push it up to Heroku!

git commit -m "adding scamp"
git push heroku master

Or for the super quick version, clone my example app.

When you've got the basic setup in place I highly recommend checking out the Scamp Readme to learn about some of Scamp's other moves.