Jack ♣

17 Jun 2018

Meet Jack, a blackjack bot for Telegram Messenger

Jack (@JackBlackTheBot) is a simple, semi-proficient Blackjack dealer for Telegram Messenger written in Node.js. He’s not too smart but Jack does all the basics, and I couldn’t be happier with how this little project turned out.

A few months ago I dove into the world of chatbots for a hackathon and was very surprised at just how easy it was to build a bot for one of the major platforms! In just under a day, our team had a Node.js powered Facebook Messenger bot up and running and were actively integrating it with various services. It was a great learning experience, and it really opened my eyes to just how powerful text-based interactions were even in this day and age.

Building Jack

With that experience under my built I decided it was time to build a bot for my own, something I could use for fun, like play blackjack with. Since I was no longer restricted to a messenger platform, I picked Telegram as my bots platform of choice. The gang over at Telegram have made it extremely easy to register a bot, and unlike other platforms where you need to hunt for API keys, Telegram have set up a Bot (@BotFather) to guide you through the whole process - super cool!

After getting the required credintials, I used bottender.js to get a simple bot server up and running. A switchcase later and custom commands were being sent to Jack. Now that the bot was set up and “live” I could focus on actually building out the Blackjack game logic. Instead of creating a deck, and randomly picking cards from it, I opted to use this Deck Of Cards api instead. I wrote a small class that generates a single blackjack hand between a “player” and a “dealer” (I was not lying when I said this was simple), and wrote some bot logic utilize the class per hand. Blackjack.js can be reused in other projects, and abstracting the blackjack logic into another class was a design decision I had commited to early on.

Deploying Jack

Here’s where things get interesting, Jack runs off a Raspberry Pi. I didn’t really want to host the server elseware, and decided that for a few days I’d run the server off something I had laying around. Using localtunnel, exposing the locally running Node.js server was very easy, and more importantly free. Im currently looking for a more permanent solution, but if you’d like to play Jack, message me and I’ll spin up the server!

Takaways

This project was very fun to build, and the output is something that is actually fun to use! I got to do some more NodeJS stuff, learned Telegrams Bot API and gained some valuable insight into the world of text-based interactions.

There’s so much more i’d like to build out for Jack, such as multiplayer (chatroom) support, betting, and quick reply (buttons). I just need time.

1. bash

Last updated: Sun May 31 17:29:48 on ttys000
Rohan-Likhites-MacBook-Pro:~ rohanlikhite$ cd Documents
Rohan-Likhites-MacBook-Pro:Documents rohanlikhite$ cat myBio.txt

About
-----/
> I am a creative software developer and product designer from Toronto, Canada. I have experience designing, building and testing robust microservice enterprise applications for IoT platforms, desktop/mobile applications, and AR/VR experiences, all using modern tech-stacks. I enjoy modern art, Formula One, green tea and play tennis in my spare time.

Skills
------/
> JavaScript + Node, Typescript, Ruby + ROR, GoLang, GraphQL, RabbitMQ, SocketIo, VueJs, Webpack, Nightwatch, Rspec, Selenium, Capybara, Intern, Jenkins, HTML5, Slim, CSS3, SASS, Bootstrap/Foundation/Chocolate, Source Code Management (GIT + SVN), Bower, Yarn, NPM, Unity3D, Open Frameworks, Processing, MAX MSP, VPT7, Adobe Creative Suite, Autocad, Revit, Oculus Rift, META SpaceGlass.

Other Interests
---------------/
-Tennis
-Reading
-Formula One
-Architecture
-Music
-Cooking

Links
-----/
Email: [email protected]
Github: imRohan
Dribbble: imRohan
LinkedIn: rohan-likhite
Twitter: @rohanlikhite
Medium: @RohanLikhite


>Press ESC to close window
>Lovingly crafted by Rohan Likhite - 2014


Rohan-Likhites-MacBook-Pro:Documents rohanlikhite$