Using MS Flow to Power a Spark Bot
In my last blog I used MS Flow to power an email to Spark bot. It allowed me to get the same type functionality that would have otherwise took a lot of STMP programing. I was pretty impressed with MS Flow and I think most of that functionality given time could be accomplished without the Azure function natively in Flow, maybe.
But Flow was so cool I figured I’d dedicate a post to just working with Flow and what’s needed to build a Spark bot without having to program. You don’t need to know any particular programing language to use Flow, but you do need to understand programing logic, and when working with Spark understand JSON and REST API to be able to piece everything together. The syntax is all drag and drop within Flow. If I need an IF statement and just click the IF button, create the condition and then complete the TRUE/FALSE bit.
This is a simple bot that listens for 1:1 messages and echos back what was said to the same Spark space and then sends you an email. With the base lines of how to call and process the Spark REST API info you can expand as needed. Flow also has pre-built triggers into all sorts of MS tools and some third-party apps. So you could use it as an easy point to pull a Twitter feed to Spark or the other way, or upload documents to sharepoint by mentioning a bot, etc etc.
Building the Bot
After we’ve created out bot we need to register a webhook on receiving a new message. We’ll add a filter so it only works on 1:1 rooms. This webhook is what will trigger the Flow. In the o365 portal we will create a new flow and the trigger point will be and “HTTP Request.” We won’t know the URL until we save the flow so we need to save building the actual Spark webhook until later. We do want to set the request method to “POST” since that is what we are expecting.
Flow can automatically build out the JSON parser based on what is expected to be received in the webhook alert so either open that option and paste in the expected output, or you can use the following JSON Schema
{“type”: “object”,“properties”: {“id”: {“type”: “string”},“name”: {“type”: “string”},“resource”: {“type”: “string”},“event”: {“type”: “string”},“filter”: {“type”: “string”},“orgId”: {“type”: “string”},“createdBy”: {“type”: “string”},“appId”: {“type”: “string”},“ownedBy”: {“type”: “string”},“status”: {“type”: “string”},“actorId”: {“type”: “string”},“data”: {“type”: “object”,“properties”: {“id”: {“type”: “string”},“roomId”: {“type”: “string”},“personId”: {“type”: “string”},“personEmail”: {“type”: “string”},“created”: {“type”: “string”}}}}}





