Additional menu
Archives
Contact information
If you have any questions or you just think that we do a good job - feel free to contact us - we <3 feedback from you!

E-mail: office[at]sicc.pl

We are SICC

Our part at Devoxx4kids 2016 conference in Poznań, Poland

Many of you may not know, but besides writing code we also love to share our knowledge. In 2015 we became the Knowledge Partner at WOW School (http://www.wowschool.pl) – programming and business school for kids running in Warsaw (so far, more info later). Our responsibility is to provide the best educational programme for children between 8-16 years and deliver it for some groups too (mostly as a beta-tests of our convictions). Last weekend we took part in international initiative Devoxx4kids – programming conference for kids (SICK!) and I want to share some thoughts after this awesome event.

Continue reading…

Slack – Azure – Raspberry Pi – episode 2

I’ve started my journey with downloading some sample code from Igal Tabachnik – xkcd slackbot (https://github.com/hmemcpy/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 asp.net (?) 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:

ConfigurationManager.AppSettings["SERVICE_BUS_CONNECTION"];

It was quite easy to manage how to make asp.net 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 😉

architecture

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 ASP.net 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!