Exploring iOS App Development: Simplifying the Process
Serverless chatbot: from idea to production at blazing speed
1. www.neosperience.com | blog.neosperience.com | info@neosperience.com
April 2017
Serverless chatbot:
from idea to production at blazing speed
Luca Bianchi,
Chief Technology Officer
2. Who am I? - Luca Bianchi @ Neosperience
CTO @ Neosperience
Working on a lot of bleeding edge technologies. Passionate developer. Love writing code, not Powerpoints.
Full stack developer, CTO, product owner, gamer..
github.com/aletheia
https://it.linkedin.com/in/lucabianchipavia
@bianchiluca
3. 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.
Neosperience Cloud
Reward
Gamification
Loyalty
Showroom
WishlistCard
Store
Customer
Context
4. Serverless User Group
• We want you!
Call for Speakers:
http://clda.co/serverless-italy
• 282 members and still growing
• Next Meetups
- Today!
- May, 18th
5. The Serverless Manifesto
✓ 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
6. The Serverless Framework (aka serverless.com)
✓ 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
7. 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!
8. conversate.eu
Conversate's innovative Natural Language Understanding platform powers high quality
chatbots and natural language interfaces
• “Conversation UX platform”
• Natural language understanding: intent recognition, entity extraction
• Conversational engine
• Optionally speech recognition and TTS
• Focused on Italian language
• Leverages Neosperience DCX capabilities to build domain-specific chatbots
9. Facebook Messenger Platform
• Build chatbots for messenger
• Chatbots are related to a Facebook Page
• Chatbots must be reviewed for approval
• Complex setup, webhook checking
• (new) App and Page users can be tracked together
11. Architecture Facebook Bot Messenger
Platform
1. send
message
2. HTTP method
call to REST 3. synch HTTP call
to conversate
4.Context
and answer
5. message sent
back to Facebook
6. Message
Messenger Hook
Service
13. Configure Messenger App
How to setup?
• Create a Facebook Page (chat bots live inside Pages)
• Create a Facebook App (optional)
• 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/
14. Serverless
How to setup?
• Start with serverless create
• Write API Gateway endpoint
• Write Lambda handler (use proxy integration)
• Persist chat context data (i.e. using DynamoDB)
• Implement REST calls to NLP platform
15. Anatomy of a service
JSON
Request Event
JSON
Response Event
Request
to Api.ai
Response
from Api.ai
16. Anatomy of a service
• When the webhook is called by Facebook, the lambda is invoked
• Parses Messenger payload and extracts user message
• Assembles conversate message requests and sends it to REST api endpoint
• Parses conversate including recognized intent and bot response
• Assembles Messenger response and sends it back to Messenger
• Administrative functions (verify token authentication, page subscription)
17. Chatbots are channels, Serverless technologies allow fast prototyping and rollout to
production, microservices enable assembling systems in no time…
An use case for a Loyalty Chatbot
Build a chatbot to support loyalty programs adoption by users.
Loyalty programs are a powerful tool to enhance customer fidelization, but have to overcome the acquisition
limit. Apps are suitable for continuous usage, but have a considerable friction because require installation.
Chatbots could be an easy and fast way to avoid users the need to install apps and provide support for
loyalty logics, rewards retrieval and action performing.
19. Architecture
Facebook Bot Messenger
Platform
1. send
message
2. HTTP method
call to REST 3. synch HTTP call
to conversate
4.Context
and answer
5. message sent
back to Facebook
6. Message
Gamification / Loyalty
Actions Services
Gamification / Loyalty
Reward Services
Messenger Hook
Service
20. The good…
• Fast time to market
• Modularity by design
• Functions can run locally
• Everything is contained and versioned
• Serverless avoids a lot of boilerplate
• Incremental deployments
• Supports CI
• Cost-effective (if you already have APIs)
21. …the bad…
• Architecture has to be enforced (no opinionated view: your code is as good as
the developer who writes it)
• Testing is unavoidable, TDD is encouraged
• Every deploy hits the cloud
• Avoid Lambda cold start issue
• Not everything is supported by CloudFormation
• Many pieces stored in different places
22. …the ugly
• Testing sometimes is a pain (no Facebook support)
• Users are not logged into the system
• Unclear approval process rules