Story of a Cerberus Bot
Transcript of Story of a Cerberus Bot
![Page 1: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/1.jpg)
Story Of a Cerberus Bot
Andrea De Gaetano - @dega1999
![Page 2: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/2.jpg)
My Typical Work Day
#Java #j2ee #j2se #spring #swing #maven
#android #gradle
#security
![Page 3: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/3.jpg)
After Work
I play a lot with:
#raspberrypi #arduino #esp8266 #iot #maker
#nodejs #python
#security
http://pestohacks.blogspot.com
![Page 4: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/4.jpg)
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?
![Page 5: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/5.jpg)
In the early 2000’s: IRC Bots
- File Sharing
- Guardians of Channels
- AntiSpam
- Ban unauthorized
- Secretary
- …
![Page 6: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/6.jpg)
In 2016Amazon Apple
Facebook Google
Microsoft …
![Page 7: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/7.jpg)
1st ImpressionWhy Should I use a Text based interface
instead a GUI?
![Page 8: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/8.jpg)
Alexa, had my attention
![Page 9: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/9.jpg)
Figuring out…My Idea was changing
![Page 10: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/10.jpg)
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.
![Page 11: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/11.jpg)
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
![Page 12: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/12.jpg)
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!
![Page 13: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/13.jpg)
Bots Models• Generative
• Retrieval-Based
• Pattern Based
![Page 14: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/14.jpg)
Generative Model
![Page 15: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/15.jpg)
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).
![Page 16: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/16.jpg)
Pattern Based Model• The bot have a list of the supported questions/
commands it support.
• Easy.
• Stupid.
• Eg. Alexa Skills
![Page 17: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/17.jpg)
@IndaqoBot• Pattern based
• 2 command supported:
• brief
• ready
• work only with Telegram
![Page 18: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/18.jpg)
Start a new Telegram Bot
![Page 19: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/19.jpg)
Bot Stack
![Page 20: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/20.jpg)
Bot Stack
Web Dyno:
use node-telegram-bot-api
talk with telegram server
accept http requests: commands
![Page 21: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/21.jpg)
Bot Stack
Web Worker
Task scheduled every hour:
• Send a broadcast message to registered users
• Call Web Dyno to change mission
![Page 22: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/22.jpg)
Keep bot state across reboots
Store Users Results: text and images*
Never used before: easy
Structure Data
![Page 23: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/23.jpg)
![Page 24: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/24.jpg)
Storing user images
![Page 25: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/25.jpg)
Storing user images
![Page 26: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/26.jpg)
Storing user images
Sad Solution: all images are converted to base64
![Page 27: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/27.jpg)
#code
![Page 28: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/28.jpg)
#code TODO
Scalability
Chat Injections
Change Model
Facebook Integration
![Page 29: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/29.jpg)
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
![Page 30: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/30.jpg)
Facebook Messenger integration
![Page 31: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/31.jpg)
Alexa#code
![Page 32: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/32.jpg)
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!
![Page 33: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/33.jpg)
Google Assistant
![Page 34: Story of a Cerberus Bot](https://reader031.fdocuments.us/reader031/viewer/2022022001/5876e6651a28ab046d8b610f/html5/thumbnails/34.jpg)
Twitter: @dega1999
Thanks you!