story of a cerberus bot
TRANSCRIPT
Story Of a Cerberus Bot
Andrea De Gaetano - @dega1999
My Typical Work Day
#Java #j2ee #j2se #spring #swing #maven
#android #gradle
#security
After Work
I play a lot with:
#raspberrypi #arduino #esp8266 #iot #maker
#nodejs #python
#security
http://pestohacks.blogspot.com
What is a Cerberus Bot?Sharing my experience on bot development
Talking about:
• Early 2000’s bots
• Why does bots matters?
• Bots Models/Architectures
• IndaqoBot: Telegram
• Bot Software Stack
• Firebase
• Improvements
• One Core , Multiple Heads: Facebook Messenger, Alexa?
• …And google assistant?
In the early 2000’s: IRC Bots
- File Sharing
- Guardians of Channels
- AntiSpam
- Ban unauthorized
- Secretary
- …
In 2016Amazon Apple
Facebook Google
Microsoft …
1st ImpressionWhy Should I use a Text based interface
instead a GUI?
Alexa, had my attention
Figuring out…My Idea was changing
User AdvantagesIntegration in known software: integrated in app or service known.. facebook messenger, skype, siri.
Users already know them: No learning curve, they can rapidly start to talk with a bot with no need to learn a new user interface.
No installation/space needed on the device: no need to install anything on their device. No need to upgrade.
User AdvantagesNatural Interaction: everyone knows how to text and speak. Attractive also for old people. A perfect bot is hard to distinguish from a real person.
Same uniform experience across devices/platforms
Developer Advantages• Userbase Potential: part of a known app (like facebook
messenger) improves the link between the real user and the owner of the bot.
• Learn new data from users through continous interaction
• One language for many platforms: web, web-mobile, desktop, mobile .
• No need to bother with accounts,login, oauth, tecnologies problems and so on!
Bots Models• Generative
• Retrieval-Based
• Pattern Based
Generative Model
Retrieval Based Model• The chatbot uses the message and context of
conversation for selecting the best response from a predefined list of bot messages.
• The context can include current position in the dialog tree, all previous messages in the conversation, previously saved variables (e.g. username).
Pattern Based Model• The bot have a list of the supported questions/
commands it support.
• Easy.
• Stupid.
• Eg. Alexa Skills
@IndaqoBot• Pattern based
• 2 command supported:
• brief
• ready
• work only with Telegram
Start a new Telegram Bot
Bot Stack
Bot Stack
Web Dyno:
use node-telegram-bot-api
talk with telegram server
accept http requests: commands
Bot Stack
Web Worker
Task scheduled every hour:
• Send a broadcast message to registered users
• Call Web Dyno to change mission
Keep bot state across reboots
Store Users Results: text and images*
Never used before: easy
Structure Data
Storing user images
Storing user images
Storing user images
Sad Solution: all images are converted to base64
#code
#code TODO
Scalability
Chat Injections
Change Model
Facebook Integration
Road to Facebook Messenger integration•Tested another bot with a raspberry pi 3, duckdns.org and letsencrypt certificate. All free! :D
•You need to register a new application on Facebook, generate a token and some other boring steps
•If the server doesn’t answer for some time, Facebook disable the bot.
•From the @IndaqoBot code, just 2 new endpoints: •one for the authentication between Facebook and the server
•one to receive messages
•Need Facebook approval to publish it
Facebook Messenger integration
Alexa#code
Advices for a Cerberus Bot•Separate logic from presentation: endpoint code must be minimal
•Create library for your code, reusable from any platform
•Write Unit Test for your libraries
•Use a storage solution to keep bot state, like firebase
•Use constants
•Use localization
•Understand the limit of each bot platform: number of simultaneous messages, user interactions and so on
•Be prepared to scale Fast!
Google Assistant
Twitter: @dega1999
Thanks you!