Slack – Azure – Raspberry Pi – episode 2

I’ve started my journey with downloading some sample code from Igal Tabachnik – xkcd slackbot ( Because I had no: experience in C#, visual studio on my computer, any idea how should it be deployed, I thought it will be fun. And it indeed was.

After getting sources of Igal’s bot, I’ve looked into the structure of (?) project. To make it working I needed some server environment. I’ve created new app service on my azure account. After that I had to rewrite xkcd bot to connect with my previously created azure service bus. To do it, I’ve used my favourite text editor (Sublime) and refactored Igal’s code. I had to edit all those configs etc manually, without visual studio’s help 😉
It was fun because I couldn’t test the solution on my local machine. After few tries I’ve managed that I can deploy my app using git directly on azure.

 git push azure master

And we’re home 😉 Here’s the final code of my controller with pushing call from slack to service bus queue (which is used by my pythin script on raspberry pi ;)):

using System;
using System.Configuration;
using System.Linq; 
using System.Net;
using System.Text;
using System.Threading.Tasks; 
using System.IO;
using System.Xml.Serialization;
using Nancy;
using Nancy.ModelBinding;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.ServiceBus.Messaging;
namespace SlackAzureServiceBus
 public class SlackRequest
 public string Token { get; set; }
 public string Command { get; set; }
 public string Text { get; set; }
 public string Channel_Name { get; set; }
 public string User_Name { get; set; }
 public class SlackAzureServiceBusModule : NancyModule
 public SlackAzureServiceBusModule() : base("/officer")
 StaticConfiguration.DisableErrorTraces = false;
 Post["/", runAsync: true] = async (_, ct) =>
 var request = this.Bind<SlackRequest>();
 if (request.Token != ConfigurationManager.AppSettings["SLACK_SLASH_COMMAND_TOKEN"])
 return 403;
if (request.Command != "/officer") return 400;
var connectionString = ConfigurationManager.AppSettings["SERVICE_BUS_CONNECTION"];
 var queue = QueueClient.CreateFromConnectionString(connectionString, ConfigurationManager.AppSettings["SERVICE_BUS_QUEUE"]);
 var payload = Newtonsoft.Json.JsonConvert.SerializeObject(request);
var payloadStream = new MemoryStream(Encoding.UTF8.GetBytes(payload));
 queue.Send(new BrokeredMessage(payloadStream,true));

return 200;

Last things I had to add to my azure app were the custom configuration fields.

Zrzut ekranu 2016-04-03 21.40.12

To access custom fields you can simply use:


It was quite easy to manage how to make azure app work (and it was my first time). This part of project has taught me a lot 😉

Slack – Azure – Raspberry Pi – episode 1

, ,

Hi there, long time – no see 🙂

I’ve been very busy lately and had not enough time to take care of my project. Today I would like to tell you something about the architecture of Officer Pi. Let me show you my idea packed into a compressed graphic file 😉


So, as you can see, basic communication between slack commands and raspberry Pi running Officer’s scripts is based on Azure service bus queue. I’ve decide to do make it happen using Azure services. As a total Microsoft-Cloud-And-All-Others-Based-Solutions-Noob© I had a really tough start. I’ve downloadaded random program from random Github Repositiory. Some of you may know, I’m working on a mac, so I don’t have a windows instance on my computer and therefore, no Visual Studio here. To build .net code I’ve used the sources and my intuition – after few hours packed with eternity spent on testing my solution on live Azure, it started working.

I’ll write more about technical aspects of this part in the next two blog posts (soon!). This is a really important milostone in my project!

Don’t count your chickens before they’re hatched

I’ve started the celebration too early. Unfortunately connection between a Raspberry Pi and my mac stopped working. I was looking for a reason for several hours and tried almost every possible configuration. I am lucky because when I was a kid, I used to use linux as my operating system, so white letters on black background hadn’t scared me off 😉

To make things working again I had to turn off the dhcpcd on a R-Pi and set everything with the static values. That was the first step. After making the boards connected I couldn’t reach any outside-local-network servers – that was a problem related to DNS. I was setting everything up using this instruction:  but one thing was missing. The blog post might be a little outdated and some things in  the Raspbian may have changed – my resolv.conf (responsible for resolving hostnames) was empty. I had to add a  DNS related line in  my /etc/networking/interfaces file:

auto eth0
iface eth0 inet static

Now my raspberry Pi has an internet connection and I can finally start some serious programming 😉
See you soon!

ps. Connecting Raspberry Pi with an ethernet cable to a Mac is not a piece of cake 😉

We’re connected!


After a few hours I’ve finally connected to my Raspberry Pi. The story is, I’ve been using it as a photobooth controller (it was a really simple project – it didn’t even had a display 😉  here you can check it out: but unfortunately currently I don’t have  a HDMI enabled screen at home and I didn’t want to spend money on buying  a display port – HDMI converter.

So I had to find a solution for communication with  my board.

I’ve found an old ethernet cable and connected it to the board. I’ve been using this method before, but I had to reconfigure network interfaces on my mac. So now, the R-Pi is connected directly to my computer using ethernet cable and it can use computer’s shared internet connection.

It works. We are connected. Big things are coming!

Hello World!

, ,

Hi, Maciek’s here. As you may know, I’m a front-end developer at SICC. Since we moved to a new office I’ve been thinking about some technological improvements, that can make our place more geeky and friendly.

That’s how OfficeR Pi idea was born. OfficeR Pi is my project created for Polish programming contest “Daj się poznać” (which can be translated as “Show yourself”). In the next 10 weeks I’ll be writing 2 blog posts a week, describing development of the process, my successes and failures.

OfficeR Pi is Raspberry Pi based office helper. I’m going to use an old lcd screen and several RPi’s modules like microphone, camera or distance sensor. Every week I’ll try to add something useful or totally useless but funny. The key idea of creating this project  is to have fun, so you may expect a lot of lolcontent here. At some point I will want to ask for your help – you will have an opportunity to vote on a new feature that should be added. The source code will be shared on my github account – I’ll provide links later.

I think that’s all I wanted to say for now, see you soon!

Christmas (Umbraco) countdown

, ,

When I know Christmas is coming…? In our busy life it’s really hard to “feel” Christmas at beggining of December, but this great posts series always alerts me that the end of year is near. Don’t know why, but it reminds me an “advent calendar” chocolates. So grab your Umbraco chocolate everyday till Christmas Eve!

Read more

Getting started with Umbraco 7 and StructureMap v3

, ,

Lately I was experimenting a little bit with Umbraco 7 and Hybrid Framework by Jeroen Breuer. It’s a great Umbraco extension, definitely worth checking. One thing I missed was some Dependency Injection (DI) container to inject custom data repositories into WebApi Controllers.  After some reaserch I decided to give a chance to StructureMap.

Although code in this example is written based on StructureMap syntax, the general way of inserting IoC/DI containers into Umbraco project should be very similar for other containers like Autofac, Ninject or Unity.

In next steps I will show how to make StructureMap works with Umbraco 7 from very empty project. The solution structure will be similar to Hybrid Framework so you could also use it as starting point.

Read more

Having a nice project to code? // +48 606 115 330