Building the @BotJurassic Twitter Bot using Logic Apps - Part 1

Building the @BotJurassic Twitter Bot using Logic Apps - Part 1


I've caught the bot bug. I've been following @ChloeCondon on Twitter for a while now, mainly for her puns and Clippy related tweets, but also for her series' on Microsoft Reactor called Got Bots?

Have you ever wanted to learn about bots, but don't know where to start? 🤖 If you're looking for a fun, safe environment to ask questions and work through various projects, demos, examples, and free Microsoft resources- this show is for you!

I'm always down for learning new things, especially if they are pointless and have the potential to annoy people, what better than building a Twitter Bot!

You can't do that with Logic Apps

First and foremost, I'm not a developer. I can write code, I frequently do, but I would in no way class myself as a Developer. I would, however, class myself as an excellent problem solver.

I'm lucky in my current role to be able to exploit that strength and be able to flex my brain working with tools and bending them to my will. One of my favourite statements is "You can't do that with X...", that to me is a challenge.

Enter @BotJurrasic, a Twitter bot built using Azure Logic Apps, Azure Table Storage, and Azure Blob Storage. I wanted to do something fun and simple as my first Twitter bot and I liked the idea of some sense of randomness in the output so I started thinking about what I could do, what tools I could use, and what would be the best way of developing and publishing the bot.

As I said, I'm not a dev, but I do regularly use things like Logic Apps as a "design first" development for a business problem. They're powerful and flexible with several built-in connectors, plus the ability to reach out to external tools such as Azure Functions, APIs, etc.


Firstly, what did I want the bot to do? Well, as anyone who works in IT knows, scope creep is real! Initially, I just wanted a bot to tweet out an update daily. Simple enough right?

Wireframe of Bot

Too simple screamed my brain, so off I went with the idea of tweeting out a random phrase from an array at a set interval, but each iteration of testing came with better ways to do something, more features, more bugs. AGILE!

The overall plan for the bot at the end was something like this:

  1. Generate a random number between 1 and 15
  2. If it equals 15 then go down Option B, otherwise, continue down Option A
  3. Option A - Tweet out a status update reading from a file in blob storage then increment that file by 1
  4. Option B - Tweet out an update consisting of 3 parts, each being pulled randomly from a table of potential options.

Background Data

Before building out the Logic App, I wanted to make sure I had the data which the connectors would call from in place.

  1. For the day counter, I went with a very simple text file stored in Azure Blob Storage, from which the Logic App can read the contents (a simple number) to use in the Tweet, along with being able to update the contents of the file.
Info of day.txt from Azure Blob Storage

2. Storing the array of names, prefixes, and suffixes was a bit more complicated as I needed to be able to pull these back by an identifier that was randomly selected. Here I turn to our old friend, Azure Table Storage which lets you store and recall semi-structured data without needing the full overhead of a relational DB such as SQL. Very lightweight and fast, so I simply created a table for each of the required fields.

List of Azure Table Storage tables

3. Last, but not least, was populating the tables with the required data. There are numerous ways to do this including the .Net library, the REST API, PowerShell, etc. but for this quick and simple use case, I've used the Azure Storage Explorer which gives you a nice clean GUI interface to all of your Blob, File Share, Queues and Tables within your Storage Accounts.

Screenshot of Azure Storage Explorer

To do this, I simply uploaded a CSV containing a list of names/phrases I wanted to use along with an ID number to each respective table which gives me an output as below! Simple right?

Contents of Names table in Azure Table Storage

Now we have all the building blocks in place to set the bot up, in Part 2, we'll go over, in-depth, how the Logic App itself is put together!