Top Banner
www.neosperience.com | blog.neosperience.com | [email protected] Serverless Usergroup November 2016 Serverless Chatbots Luca Bianchi, Chief Technology Officer @ Neosperience Janos Tolgyesi, Team Leader iOS @ Neosperience github.com/aletheia https://it.linkedin.com/in/lucabianchipavia @bianchiluca github.com/mrtj https://it.linkedin.com/in/janostolgyesi
17

Chatbot Meetup

Jan 24, 2018

Download

Software

Luca Bianchi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chatbot Meetup

www.neosperience.com | blog.neosperience.com | [email protected] Usergroup

November 2016

Serverless Chatbots

Luca Bianchi, Chief Technology Officer @ NeosperienceJanos Tolgyesi, Team Leader iOS @ Neosperience

github.com/aletheia

https://it.linkedin.com/in/lucabianchipavia

@bianchiluca

github.com/mrtj

https://it.linkedin.com/in/janostolgyesi

Page 2: Chatbot Meetup

Who are we?Working on a lot of bleeding edge technologies. Passionate developers.

Love writing code.

One of us speaks Magyar very well, guess who? :-)

The Neosperience Cloud• Software as a service cloud for Digital Customer Experience processes (couponing, gamification, proximity, etc.)

• Completely built on AWS

• Moved from VMWare, to EC2, to Elastic Beanstalk, to Lambda

• Dozens of micro and nano services

NeosperienceThe Digital Customer Experience Company, aims to change the way brands and customers interact with an

approach of a software vendor targeting Digital Customer Experience as the evolution of Marketing automation.

Page 3: Chatbot Meetup

✓ Functions are the unit of development and scaling

✓ No machine, VMs or containers visible in the programming model

✓ Permanent storage lives elsewhere (stateless code)

✓ Scales per request. Users cannot over or under-provision capacity

✓ Never pay for idle

✓ Implicitly fault tolerant

✓ BYOC - Bring Your Own Code

✓ Metrics and logging are an universal right

The Serverless Manifesto

Page 4: Chatbot Meetup

The Serverless Framework (aka serverless.com)

• Started less than one year ago (was named JAWS) • Fast moving (with a bi-weekly release model) • Funded by a 3M investment • Manages service deployments and provisioning • Vendor independent (in a future release)

• Auto-provision of resources

• Supports for micro-services

• Improved plugin management system

• Production ready

Page 5: Chatbot Meetup

Getting started

• Install Serverless locally (trust me, it’s better) npm install serverless —save

• Create a function in NodeJS (Java and Python supported too)serverless create —template=aws-nodejs

• Deploy serviceserverless deploy

done!

Page 6: Chatbot Meetup

ArchitectureFacebook Bot Messenger

Platform

Messenger HookService

1. send message

2. HTTP methodcall to REST

3. synch HTTP call to api.ai

4.Context and answer

5. message sent backto Facebook

6. Message

Content DataService

3.2 TextualAnswer

3.1 Api.ai Webhook

Page 7: Chatbot Meetup

Introducing Api.ai

• “Conversation UX platform”

• Natural language understanding: intent recognition, entity extraction • Conversational engine

• Optionally speech recognition and TTS • Predefined conversational domain (eg. “Small Talk”)

• Integration with various chat platforms • Free tier

http://api.ai/

Page 8: Chatbot Meetup

Facebook Messenger Platform

• Build chat bots for Messenger

• web-hook based callbacks • relatively complex setup (Page, App, verify token, etc.)

Page 9: Chatbot Meetup

Step 1: Create bot on api.ai

• Create intents: sample phrases (utterances)

• (Optional) Create entities: attributes of intent, to be extracted from user response • Enabled domains if needed (Small Talk)

• api.ai webhooks: content data service • api.ai integration API: we will use this!

http://api.ai/

Page 10: Chatbot Meetup

Step 2: Configure Messenger App

• Create a Facebook Page (chat bots live inside Pages)

• Create a Facebook App • Setup webhooks: Messenger will send here the messages of the user

• Security considerations: verify token and page access token • Subscribe app to page events (eg. new message)

• Receive messages and postbacks, and send structured response

https://developers.facebook.com/docs/messenger-platform/

Page 11: Chatbot Meetup

What’s inside a Service?

JSON Request Event

JSON Response Event

Request to Api.ai

Response from Api.ai

Page 12: Chatbot Meetup

Step 3: Lambda connects the two worlds

• When the webhook is called by facebook, the lambda is invoked

• Parses Messenger payload and extracts user message • Assembles api.ai message requests and sends it to REST api endpoint

• Parses api.ai responds including recognized intent and bot response • Assembles Messenger response and sends it back to Messenger

• + administrative functions (verify token authentication, page subscription)

Page 13: Chatbot Meetup

ArchitectureFacebook Bot Messenger

Platform

Messenger HookService

1. send message

2. HTTP methodcall to REST

3. synch HTTP call to api.ai

4.Context and answer

5. message sent backto Facebook

6. Message

Content DataService

3.2 TextualAnswer

3.1 Api.ai Webhook

Page 14: Chatbot Meetup

The good..

• Fast time to market (the whole project built in 8h)

• Modularity by design • Functions can run locally

• Everything is contained and versioned • Serverless avoids a lot of boilerplate

• Incremental deployments • Supports CI

• Cost-effective • Api.ai acquired by Google (now with support for Italian language)

Page 15: Chatbot Meetup

..the bad

• Architecture has to be enforced (your code is as good as you)

• Testing is unavoidable, TDD is encouraged • Every deploy hits the cloud

• Cannot test offline (no matter how you try) • Avoid Lambda cold start issue

• Not everything is supported by CloudFormation • Many pieces stored in different places (maybe CloudFormation CustomResource?)

Page 16: Chatbot Meetup

Thank you

github.com/aletheia

https://it.linkedin.com/in/lucabianchipavia

@bianchiluca

Slides available on Slideshare

http://bit.ly/2fZMM2Q

Try our Neosperience DCX Bot http://m.me/neosperience

github.com/mrtj

https://it.linkedin.com/in/janostolgyesi

Page 17: Chatbot Meetup

www.neosperience.com | blog.neosperience.com | [email protected]