A Chatbot Solution PoC powered by AWS Lex
Introduction
Adding a highly engaging chatbot to your web sites can create immediate customer value. For example a support bot that helps your customers right on the spot can improve customer experience and enhance brand image.
A support bot can be a customer support bot that serves external end users or a bot supports internal staff e.g. as a complement of IT Support team.
The underline architecture should be the same for customer support bot and internal support bot.
Scope
From an architectural perspective, what I want to achieve in such a PoC exercise includes technology selection, assessment, feasibility analysis, understanding of the involved technology components/systems, and the attempt to piece them together to form an end-to-end solution. The detailed-level implementation - e.g., UI details, a complete and sophisticated Bot capability - which can be enriched on an ongoing basis - is not the focus of this PoC. Having said that, the PoC itself delivers a preliminary end-to-end solution.
Introducing AWS Lex
Amazon Lex is an AI service for building conversational interfaces using voice and text with which developers can build applications with engaging user experiences and lifelike conversational chatbots.
It is based on the same deep learning technologies that power Amazon Alexa. Under the cover, it utilizes automatic speech recognition (ASR) for converting speech to text, and natural language understanding (NLU) to recognize the intent of the text.
Introducing AWS Lambda
AWS Lambda is "serverless" technology meaning it lets you run code without provisioning or managing servers, although the code is still executed by a short-lived running environment - .e.g. a JVM instance inside a container.
The more frequent the code is used, the faster instantiation of the running environments - they typically load up in milliseconds upon requests. AWS Lambda takes care of automatic horizontal scaling for up to 1000 concurrent running instances.
With Lambda, you pay only for the compute time you consume - there is no charge when your code is not running.
You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app like calling a web service.
Solution Architecture
At a high level, this chatbot solution consists of three tiers: Client Channel, Conversational Interface and Intent Fulfillment Services.
Conversational Interface
- What is the intent of the client?
- What input parameters are needed in order to fulfill the intent?
- Which service can fulfill the intent?
The conversational interface of a chatbot is the "AI" portion which enables humanized conversation and identify the intent of a user.
Based on the type of the intent, the interface will then collect all the parameters that are necessary to fulfill the intent.
For example, “I want to order a pizza.” would trigger a “Order pizza” intent, and “type of pizza”, “size” and “delivery time” need to be collected for the client in order to fulfill the intent.
AWS Lex is an implementation of conversational interface.
Client Channel
- By what means clients can interact with the bot?
- Who can interact?
Client Channel provides means for end users to interact with the bot. These typically include a browser, a mobile device and some messaging platform such as Facebook Messenger and Slack Channel.
AWS Lex supports the integration of five channels:
- Facebook (Supports both web embedding and mobile) - This channel is implemented in this PoC.
- Kik (mobile only) - This channel is not attempted.
- Slack (Slack subscription required) - This channel is implemented and tested during PoC but not documented here.
- Twillio SMS (mobile SMS only) - This channel is not attempted.
- Web UI (AWS Javascript SDK) - Implemented and tested by this PoC. AWS console does not include this method as channel integration and it is most complex way to integrate. This channel is ideal for our use cases.
Intent Fulfillment Services
Intent fulfillment can be getting some information as a response - e.g. getting supporting information for a given application name - or performing some system actions - e.g. retrieving client's account balance.
Typically intents are fulfilled by calling back end services which include AWS Lambda functions and web services, or a combination of the two.
Facebook Channel Solution Architecture
Facebook channel is a good choice for retail businesses. As most companies block social networking sites like Facebook, it is not ideal for clients accessing applications from their company network.
To integrate with Lex, a Facebook App is created which hooks up with a Facebook page for messaging via Messenger.
Facebook Channel Architecture Diagram
The diagram below depicts the high level architecture of Lex and Facebook channel integration.
Facebook Channel Screen Sample
The screenshot belown shows channel integration with Facebook App which handles messaging via Messenger App.
Facebook Channel Screen Sample 2
The screenshot belown shows channel integration with Facebook chat plugin.
Web Channel Solution Architecture
Web channel is more applicable to most use cases because it does not require an intermediate messaging layer, however more development work is required in order to communicate with Lex directly. Amazon Cognito is used for user login for this PoC.
Web Channel Architecture Diagram
The diagram below depicts the high level architecture of Lex and web channel integration.
Web Channel Screen Sample
The screenshot belown is from a sample web page with web channel integration.
Integration Pattern
The back-end intents and fulfillment services can be enhanced and deployed independently of the web client channel. The web channel component can be deployed as an independent web application and can be embedded in parent web sites using HTML iframe. What sites (internal or external) can host and/or embed this bot (CORS) is configurable for security control.
Conclusion
A humanized conversational support bot could quickly enhance client experience and service satisfaction. AWS Lex and AWS Lambda can be leveraged to implement an end-to-end cost effective support bot solution. With the proposed architecture, developers can simply focus on creating robust fulfillment services. The capability of the support bot can be expanded gradually as new intents and respective fulfillment services can be added along the way.