elastic blog

Categories


elastic blog

#easterbot – behind the scenes

Learn how we’ve connected our Elastic Forms chatbot with Raspberry Pi, SharePoint, Azure Functions, Microsoft Flow and Cognitive Services

Rafał HryniewskiRafał Hryniewski

If you’ve had seen our easter installation you’re probably interested how we’ve made it. Let’s talk a bit how we’ve managed to use newest technologies like serverless and IoT to achieve it.

All endpoints are easily connected using Microsoft Flow

There were two fundamental building blocks for the entire installation. First was our product – Elastic Forms and simple form with the conversational interface. We believe this is a natural way to fill forms in the age of social media and communicators. 

Learn how easily you can create forms, surveys and chat bots using Elastic Forms:

What’s even more amazing is fact that we were able to integrate our application with all other components almost without any changes in our application code, to be honest, we’ve made two changes that I’ll mention later.


Elastic Forms form in the conversational mode

The second important environment is Microsoft Flow which allowed us to integrate with APIs like Cognitive Services, external HTTP endpoints or Azure Functions with ease and simplicity. Microsoft Flow is great service which allows creating even complicated workflows in the browser from blocks. Everything without the requirement of advanced technical knowledge and/or introducing major changes in existing applications.

The first thing we’ve needed was planning process. After some brainstorming, we’ve agreed to version which you were able to see in action. First, you would enter Elastic Forms web page which we’ve deployed to Azure. Then you would authenticate yourself with a Twitter account and proceed to fill a conversational form with recipient’s Twitter handle, greetings text, and select few interactive options. That’s everything you could do on your end. After that entire form was posted to our Elastic Forms application.

Because we’ve integrated our product with Microsoft Flow we’ve managed to redirect entire process to Microsoft Flow. Posted form was saved in our application and our custom MS Flow block fetched its contents and passed them further.

First stop along the way was two blocks with HTTP Requests that queried Microsoft Cognitive Services. To be specific first one detected used language based on input from form and second was text moderation in received language which together prevented usage of abusive and inappropriate language.

Only after we ensured that wishes were, in fact, sincere and polite we’ve continued to last step in this particular flow. This one pushed your wishes to SharePoint list which provided storage.

Everything after that was done by the second flow. This one triggered every one minute.

The first action in this flow fetched next entry in mentioned SharePoint list with wishes. Entry was posted to our Elastic Forms API which was using SignalR to notify web page viewed on our iPad about new wishes and changed them seamlessly in real time, without any page reload. This API was first of two changes we’ve made in our application for this event. We’ve used SignalR because it’s simple, reliable and really easy to implement, we’ve done this before in our Elastic Intranet application to introduce real-time refreshing of comments and we couldn’t imagine anything better for this purpose. That’s how you’ve been able to see your wishes on our live stream in real time.

If there were any new entries and user selected those options during a conversation with our form, we were executing HTTP to endpoint provided by our Raspberry Pi which turned on the lights and some other fancy easter decorations.

Next step in our flow invoked Azure Function, another great service from Azure which allowed us to execute some code outside of our application and infrastructure. This function taken entire input requested a photo from our camera which we’ve used for live streaming composed everything into a short tweet and posted it to Twitter, for the entire world to see.

Could we just code everything into some makeshift solution and deployed it? Yes, we could. But we wanted as many great, fun tools for that. Also, we’ve wanted to introduce as little changes to our entire application as possible. We’ve managed to do all those integrations with only two changes in code. First, one was adding SignalR and simple API endpoint to refresh displayed wishes, the second one was two lines of code for Twitter authentication (most of that came out of the box with Azure App Service anyway). All of that was possible because, in place of the bazillion of integrations we’ve integrated Elastic Forms with Microsoft Flow, I can sincerely say – it’s mother of all integrations.

That’s how we’ve done and we hope you enjoyed it at least that much as we’ve had fun making all of this for you 👋

I'm developer at Elastic Cloud Solutions. After hours I'm passionate .NET Dev, blogger and speaker. I love playing with cloud, distributed systems, actor model and databases.

Comments 0
There are currently no comments.