2. 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
Neosperience
The 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.
3. ✓ 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
4. 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
5. 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 service
serverless deploy
done!
6. Architecture
Facebook Bot Messenger
Platform
Messenger Hook
Service
1. send
message
2. HTTP method
call to REST
3. synch HTTP call
to api.ai
4.Context
and answer
5. message sent back
to Facebook
6. Message
Content Data
Service
3.2 Textual
Answer
3.1 Api.ai
Webhook
9. 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/
10. 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/
11. What’s inside a Service?
JSON
Request Event
JSON
Response Event
Request
to Api.ai
Response
from Api.ai
12. 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)
13. Architecture
Facebook Bot Messenger
Platform
Messenger Hook
Service
1. send
message
2. HTTP method
call to REST
3. synch HTTP call
to api.ai
4.Context
and answer
5. message sent back
to Facebook
6. Message
Content Data
Service
3.2 Textual
Answer
3.1 Api.ai
Webhook
14. 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)
15. ..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?)