My family uses Slack. It’s pretty interesting.

Everything changed for the better when we started using slack at work. We’ve made countless custom integrations; doorbells, intercoms, travel cards, reddit, lunch menues, git hooks, server monitoring, you name it – we haz it.

My family has been using Google Calendar for a few years. Me and my wife used to think that we we’re busy every night and that there was no room for improvisation. Google Calendar showed us that we had lots of free evenings and weekends, which has been great.

When it was time to evaluate a group chat app, I saw no reason to use HipChat, Skype or anything like that. Slack to the rescue!

Slack’s free tier gives us 10 integrations, search for the latest 10 000 messages and 5GB storage. This is plenty for a family of 4. In this blog post I’ll go through how we use it and the integrations we have made to aid us.

Screen Shot 2016-02-01 at 15.15.44

We use channels just the same way we use them at work. “fixahuset” is a channel for stuff that needs to be fixed around the house, “general” is important stuff, “handla” is for picking up milk on the way home, “mathem” is an integration i’ll get to in a bit, and “random” is the usual cat gif mayhem we’ve all learned to love/hate. “pedertest” is where i test new integrations.

Integration no 1: Where are the kids?

We, as most parents to 10yo kids, ask this question daily. Picking them up at school, but they’re at a friend’s house, etc. Gah. This is a custom Slackbot command, which calls out to my server and returns the result.

My server runs a little curl script that calls out to Find My iPhone and returns a static GoogleMap image. The kids will probably start to question this thingie eventually, but works for now.

whereis

Integration no 2: Google Calendar

Our old Google Calendar integrates very smoothly, just hook it up and let Slack know when you want the notifications.

Screen Shot 2016-02-01 at 15.27.16

Integration no 3: School information

It turns out our school is living in the future, providing a RSS-feed per child. I had no idea. RSS works very well with this setup.

Screen Shot 2016-02-01 at 15.32.12

Integration no 4: Online food shopping

In Sweden, MatHem is one of the biggest e-commerce sites for groceries. We use them for a weekly delivery, and it works great. The night before delivery we generally take 10 minutes and cram everything we can come up with into our cart, which means that we miss a lot of essentials. What if we could add uhm… juice to our cart throughout the week, the moment when someone realise that we’re out of uhm… juice (“sök” means search, “köp” means buy).

mathem-animation

This integration is not kosher at all, and I’m probably breaking some terms and conditions. But we need this, and it could be done, so hey. If you work at MatHem or is offended by this in any way – please let me know and I’ll cease and desist.

That’s all the stuff we’ve got now, but more to come. Applying tactics from work to family life may seem cold, but I see this as a way to make the most out of our time. It’s not like we’re writing Jira stories or planning our vacation in Trello. Yet.

UPDATE

Lots of people wrote and talked about this, like Qz.com, ForbesNyTeknik (Swedish) and Apparat (Russian). And on Twitter (1) (2) (3) (4), Hackernews and Fatherly.com. CBC Spark also made an interview, which was great fun.

Hooking up the voice intercom to Slack

The intercom from the street to our office was connected to an old GSM phone, and letting people in required us to pick up the phone and press the digit 5. Simple, sure, but it doesn’t feel like 2015. I had also been meaning to try the Twilio API for some time.

Task: Connect the Intercom to Slack.

The Twilio API is great, so it was actually really easy to accomplish. I bought a local number and asked our landlord to forward the Intercom to it. Then I set up this simple TwiML script on a web server:

<Response>
  <Say>Welcome to Earth People. Please stand by.</Say>
  <Enqueue waitUrl="http://x.urtp.pl/slack/service_porttelefon_wait.php"> </Enqueue>
</Response>

What happens here is that Twilio will pick up the call and greet the intercom user using Twilio’s text to speech service. It will then put the “call” into a new phone queue. Twilio will generate a phone queue id and pass it via POST to the waitUrl, below:

<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
file_put_contents('input_porttelefon.txt', $_POST['QueueSid']);
# curl post to slack
$data = array(
  "channel" => "#general",
  "username" => "Intercom",
  "text" => "Meep Meep! Open the door with 'Intercom'",
  "icon_emoji" => ":door:"
);
$url_send = "https://hooks.slack.com/services/xxx/xxx/xxx";
$str_data = json_encode($data);
$ch = curl_init($url_send);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str_data);
curl_exec($ch);
curl_close($ch);
?>
<Response>
  <Play>http://x.urtp.pl/slack/DrOctagon_EarthPeople.mp3</Play>
</Response>

The waitUrl will save the phone queue id to a text file, make an incoming webhook to Slack and of course play a funky tune to the intercom user. Now Twilio will play the funky tune until it ends, or an incoming HTTP-request is made to the Twilio REST API, using the queue id.

Slack is set up to make an outgoing webhook to a URL. This URL just pops the only call in the queue to the front of the queue.

<?php
# when incoming hook: read call sid from file and call twilio.
$QueueSid = file_get_contents('input_porttelefon.txt');
if(strlen($QueueSid)>2){
  require_once('TwilioPHP/Twilio.php');
  $sid = "xxx";
  $token = "xxx";
  $client = new Services_Twilio($sid, $token);
  $member = $client->account->queues->get($QueueSid)->members->get("Front");
  $member->update(array(
    "Url" => "http://x.urtp.pl/slack/service_porttelefon_dtmf.xml",
    "Method" => "GET"
  ));
  file_put_contents('input_porttelefon.txt', '');
  echo '{"text": "Ok, opened."}';
}else{
  echo '{"text": "No one is at the door."}';
}

The last step is to have Twilio play the sound of the digit 5, which opens the door, using the same kind of XML as step 1. Easy!

Next up is to let intercom users, which we don’t let in for some reason, leave a voice message which is posted to Slack. Totally doable, but not we’re quite there yet.

/Peder

How to make a wind chime door bell

Our doorbell was already connected to the Internet via an Arduino, but we couldn’t stand the sound it made. We needed a warmer sound, a sound that didn’t make us want to kill the doorbell users (mostly clients).

Step 1:
Buy an old Wind Chime, preferably with a coconut base (because awesome).
2015-01-22 14.34.26

Step 2:
Pick up a few Littlebit modules (Cloudbit, servo motor and power supply).
2015-01-22 15.41.33

Step 3:
Drill, glue and duct tape a bambu stick to the servo motor. Hide all the crap in a classy box.
download_20150122_143926

Step 4:
Make the old Slack door bell script also make a little curl post to the Cloudbit.

<?php
$data = array(
	"percent" => "100",
	"duration_ms" => "10000"
);
$url_send = "https://api-http.littlebitscloud.cc/devices/XXX/output";
$str_data = http_build_query($data);
$ch = curl_init($url_send);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer XXX','Accept: application/vnd.littlebits.v2+json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
echo curl_exec($ch);
curl_close($ch);

Step 5:
Ring the door bell. Voila!
doorbell

Let Slack nag you that it’s time to return that commuter pass

Another week, and yet another Slack integration here at Earth People.

This time we’ve added an integration to the public transport system here in Stockholm.

At Earth People we like to use public transportation when going to meetings with clients. That’s why we have bought a couple of commuter passes that we can use whenever we need to go to a meeting.

It works great. But there is one problem however: we only have a few cards, so when you return from the meeting you must remember to return the card so others can use it. And that’s were our latest integration comes into play:

Screenshot showing a message posted to a slack channel, with the date and time of a journey Yup, shortly after the card has been used, a message from the card will appear in our slack channel. That works pretty good as a reminder.

And as a plus feature it also shows how much cash that is left on the card, so we will also know when it’s time to refill the card.

There you have it: another super useful integration for Slack.

Oh! And thanks to mysl for their API-wrapper for “Mitt SL”, that led us into the right direction when researching the API.