Creating a ChatBot with BotMan
Tags: botman, chatbot, laravel, php
Published: 2018-10-18 21:20:26

---
title: Creating a ChatBot with BotMan
published: true
tags: botman, chatbot, laravel, php
canonical_url: https://davidllop.com/creating-a-chatbot-with-botman
---

Last month I was interested in all this chatbot thing, specially in the features Google Allo has. In that messaging app, you can set a reminder to get notifications about the weather daily in the morning, or to receive jokes / fun facts at specific times.

I had a problem every day with my city bike system. The nearest station from home is used by a lot of people, and some morning there are no free bikes when I arrive there, so I need to walk to the next station (and reach late at work because I'm a lazy person and I always leave home at the last possible moment 😓).

So I thought:
> What about a bot that tells you every morning the number of free bikes at a preferred station? 

I checked the website of the city bike's company but it’s difficult to use from the smartphone. I needed a better way to know the information of the station every day.

I follow [Marcel Pociot](https://twitter.com/marcelpociot) on Twitter for almost two years, so I decided to check what  [BotMan](https://botman.io) is about since I saw a lot of tweets mentioning it. It is a PHP framework to create bots in an easy way, and also installable in a Laravel app, it was the perfect solution for what I wanted to do! 🙌

A month later, I have a chatbot currently running in production and telling me each morning the number of free bikes my station has, telling me the same information about the station near work from monday to friday. I went a bit further and added a bunch of cool features:

- You can share your location and the bot will show you the 3 nearest stations with a link to Google Maps to get directions (don’t worry I’m not storing that information and selling it to local companies).
- You can create aliases for a station so that it is easier to ask for information. There are 19 stations right now and it’s difficult to remember all the names, so you can create aliases like `gym` or `home` to ask for information about a specific station.
- I added some travel information. For example `from gym to home`  and it will show you the availability of the two stations and the distance between them (just in a straight line, sorry guys I’m not Google 😅 ).
- You can define a station as a preferred one, so every time you say `hello` the bot will show you the information of that station. It can’t be quicker in my opinion 🙂.


<br>

![Example of the bot](/media/posts/botgirocleta.gif)


Reminders are customizable for specific days of the week or timings, and you can choose between getting information about free bikes or free parkings. They are sent using [Laravel Task Scheduling](https://laravel.com/docs/5.6/scheduling) feature. It’s amazing how simple it was to have it running.

This is my most enjoyable hobby project. I’m still adding features to it and planning to talk about it with other bike users. My girlfriend is already using it and has some great ideas to add as future improvements.

If you’re curious about building a chatbot or how they work, don’t hesitate to check [BotMan](https://botman.io)’s website or send me a tweet, I'll help you as much as I can. 🤓

I also want to mention [Matt Stauffer](https://twitter.com/stauffermatt?lang=ca) for his great talk at [Laracon Online 2018](https://laracon.net) about side projects and enjoying what you do (You can get access to this year’s videos for just $25 (20€). I saw it live and I totally recommend watching it.