Check Stock on the Go with a Messenger, Telegram or SMS Bot

This tutorial will show you how to build a bot that can look up stock. We’ll be using the simple code-free tools provided by Flow XO to search for stock items on a Google Sheet and send a message back to the user with the details of the found item.

The bot can be accessed via Messenger, Telegram, Slack and SMS (Twilio) making is easily accessible as well as being super convenient. You can just send a quick message to find out if an item is in stock. Imagine the amount of time you could save by not having to flick through catalogues or log onto websites to check stock!

What you will learn

  • Collecting data using a bot
  • Searching a Google Sheet
  • Filtering Messages based on search results

You can install the flow used for this tutorial using the below link.

What is Flow XO

Flow XO is providing an easy to use, code-free, bot building platform with a long list of integration services. All the tools you need to build bots that are not only extremely useful but are also very easy to use. If you don’t have a Flow XO account already, you can sign up for free!

To build a bot, we create a flow which will contain the step by step logic (tasks) that will control how the bot works as well as the integration logic for Google Sheets.

There are conditional filters that can be used for each task so that you are able to decide whether an action should or shouldn’t be carried out and there are over 90 integration services that you can use, enabling so many different use cases to be built.

Building the Bot

Building the bot is nice and simple. It literally took me about 3 minutes to put this bot together! And now I have a bot that can check the stock level of items. Being able to access the bot via various supported platforms makes it accessible as well as being really easy to use.

We’ve used filters to decide what message is sent to the user depending on whether the item code provided was found and if there is an expected date for new stock. This allows us to tailor the response to the user.

Completed Flow

Step 1: Trigger

We’re triggering the flow using the Bot — New Conversation trigger. As soon as the bot has been triggered, we’ll ask the user for the item number that they wish to check the stock for.

Step 2: Get the item number

We’ve used the Bot — Ask a Question to ask the user to provide the item number.

Question — what’s the item number

Step 3: Search for the item number

Next, we’re searching for the item number in the Google Sheet. Our Google Sheet has three columns, the item code, the stock level and the ETA.

Google Sheet

We search for the item number in the ‘Item Code’ column.

Google Sheets — Search Rows

Step 4: No results found message

The next action is a Bot — Send Message. This message lets the user know that we didn’t find any matches for the item code provided.

We make sure that this message is only sent when there are no matches found by adding a filter that checks to see if the Row Count (returned when we search Google Sheets) is equal to zero. If we don’t have any rows, then we didn’t find any matches.

We’ve also ticked the option to stop the flow if the filter conditions are met because there are no further tasks that we need to run if we didn’t find any matches.

No Results Found Filter

Step 5: Results found without ETA date

The next task in the flow is another Bot — Send a Message. This message lets the user know how many items we have in stock.

We’re using the results from the search to populate the stock level and item code values. The type of output returned from a Google Sheet is a Collection Output. You can specify row numbers like below, which would give us the second row of the results.

{{search_item_code.results_+_gsx:stocklevel 2}}

As we are only expecting one result, we’ve not provided a row number, which will select the first row in the collection.

Bot — Send Message (No ETA)

We’ve also added filters to this task to check that the row count is greater than zero (we want to make sure that we do have some search results) and that the ETA is empty. We’ve also selected the option to stop the rest of the flow if the conditions are met.

Message Without ETA Filter

Step 6: Results found with ETA date

The last task in the flow is very similar to the first but this time we are including the ETA (expected arrival date) for new stock.

Again, we’ve added filters to this task to check that the row count is greater than zero and that the ETA is not empty.

Message with ETA

What Else Can We Do?

This bot relies on the user knowing the item code but you could add a column to contain keywords/phrases for the items and you could search that column instead. So if I sold Duracell AA batteries in a pack of 8, I could use the phrase AA Batteries so if the user searched for AA batteries, the Duracell AA Batteries item would be matched. You’d be able to use the Collection Outputs logic to display a message containing the list of matched items.

You could even provide alternatives for out of stock items. You could use a separate column or sheet to hold alternative item codes so if the row count on the first search was zero, you could search for alternative items and provide the user with a message to let them know that the item they wanted is out of stock but you could offer them an alternative. You could again apply filters to the message to ensure that the alternative was in stock so that the message wasn’t sent if there was no stock.

The Finished Bot

In just a few minutes, we’ve built a bot that can check stock via Messenger, Telegram, Slack and SMS (Twilio). It’s simple and easy to use as well as providing a very useful service that so many people could benefit from.

The Finished Bot in Action