chatbot meetup
TRANSCRIPT
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
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.
✓ 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
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
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!
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
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/
Facebook Messenger Platform
• Build chat bots for Messenger
• web-hook based callbacks • relatively complex setup (Page, App, verify token, etc.)
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/
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/
What’s inside a Service?
JSON Request Event
JSON Response Event
Request to Api.ai
Response from Api.ai
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)
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
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)
..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?)
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
www.neosperience.com | blog.neosperience.com | [email protected]