story of a cerberus bot

34
Story Of a Cerberus Bot Andrea De Gaetano - @dega1999

Upload: dega1999

Post on 23-Jan-2018

289 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Story of a Cerberus Bot

Story Of a Cerberus Bot

Andrea De Gaetano - @dega1999

Page 2: Story of a Cerberus Bot

My Typical Work Day

#Java #j2ee #j2se #spring #swing #maven

#android #gradle

#security

Page 3: Story of a Cerberus Bot

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

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

In the early 2000’s: IRC Bots

- File Sharing

- Guardians of Channels

- AntiSpam

- Ban unauthorized

- Secretary

- …

Page 6: Story of a Cerberus Bot

In 2016Amazon Apple

Facebook Google

Microsoft …

Page 7: Story of a Cerberus Bot

1st ImpressionWhy Should I use a Text based interface

instead a GUI?

Page 8: Story of a Cerberus Bot

Alexa, had my attention

Page 9: Story of a Cerberus Bot

Figuring out…My Idea was changing

Page 10: Story of a Cerberus Bot

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

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

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

Bots Models• Generative

• Retrieval-Based

• Pattern Based

Page 14: Story of a Cerberus Bot

Generative Model

Page 15: Story of a Cerberus Bot

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

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

@IndaqoBot• Pattern based

• 2 command supported:

• brief

• ready

• work only with Telegram

Page 18: Story of a Cerberus Bot

Start a new Telegram Bot

Page 19: Story of a Cerberus Bot

Bot Stack

Page 20: Story of a Cerberus Bot

Bot Stack

Web Dyno:

use node-telegram-bot-api

talk with telegram server

accept http requests: commands

Page 21: Story of a Cerberus Bot

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

Keep bot state across reboots

Store Users Results: text and images*

Never used before: easy

Structure Data

Page 23: Story of a Cerberus Bot
Page 24: Story of a Cerberus Bot

Storing user images

Page 25: Story of a Cerberus Bot

Storing user images

Page 26: Story of a Cerberus Bot

Storing user images

Sad Solution: all images are converted to base64

Page 27: Story of a Cerberus Bot

#code

Page 28: Story of a Cerberus Bot

#code TODO

Scalability

Chat Injections

Change Model

Facebook Integration

Page 29: Story of a Cerberus Bot

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

Facebook Messenger integration

Page 31: Story of a Cerberus Bot

Alexa#code

Page 32: Story of a Cerberus Bot

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

Google Assistant

Page 34: Story of a Cerberus Bot

Twitter: @dega1999

Thanks you!