magento live australia 2016 facebook chatbot for magento
TRANSCRIPT
![Page 1: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/1.jpg)
![Page 2: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/2.jpg)
A Facebook Chat Bot Using Magento 2 Async Processing
![Page 3: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/3.jpg)
Magento 2 Architect
Eugene Tulika @vrann
![Page 4: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/4.jpg)
Use-Case: Store With Hand-Picked Books
![Page 5: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/5.jpg)
Niche Customers With Unusual Requests
![Page 6: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/6.jpg)
Facebook Page
• Facebook is the best way to reach larger and targeted audience• Facebook Page representing the store• Customers don’t want to leave Facebook to shop in store• Customers ask questions in Messenger
![Page 7: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/7.jpg)
Facebook Chat Bots
• When store Manager cannot handle all communications manually• Facebook webhooks for messages received in the chat• Facebook API for responses
![Page 8: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/8.jpg)
Facebook POSTs Messages to the Callback
Callback.php200 OK
![Page 9: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/9.jpg)
Callback POSTs Response to Facebook API
![Page 10: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/10.jpg)
Understanding the Conversation
![Page 11: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/11.jpg)
How to Convert Messages to Magento API Requests
Input Classifier
Search catalog by author
Title, image url, description
![Page 12: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/12.jpg)
Quadrant of Conversation Parsers
Image from https://www.quora.com/What-is-the-best-way-to-learn-and-write-a-AI-Chat-bot
![Page 13: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/13.jpg)
Wit.AI Retrieval Conversation Setup
![Page 14: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/14.jpg)
Conversation Parsing
• https://github.com/vrann/phpwit
Do you have a book by Proust?
Intent: catalog_searchParameters: Author: ProustInvoke: catalogSearch(context)
![Page 15: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/15.jpg)
Integration With Magento
IN/OUT integration Using Web API
![Page 16: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/16.jpg)
On average, Magento store has integrations with 15 different external systems
Integrations Framework:• API In supported by Web API (CE) and RabbitMQ (EE)• API Out supported by RabbitMQ (EE)
![Page 17: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/17.jpg)
Callback Makes API Request to Magento
Messenger Callback.php
API
Web API Request
Magento POSTs response to Facebook
![Page 18: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/18.jpg)
Web API Service Interface
![Page 20: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/20.jpg)
Map Service to the Web API Endpoint
![Page 21: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/21.jpg)
What Can Go Wrong?
When customer writes in Messenger:• Blocking request from callback to Magento• Scalability: Magento can be overloaded processing other requests• Availability: Magento API is unreachable at that moment
Messages from customer can be lost!
![Page 22: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/22.jpg)
API IN Using RabbitMQ
![Page 23: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/23.jpg)
Callback Puts Messages to the Queue
• Scripts: https://github.com/vrann/http-rabbitmq-writer
Messenger
API
Callback.php
Magento POSTs response to Facebook
Rabbit MQ
![Page 24: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/24.jpg)
Transformation of Web API to Inbound Calls via RabbitMQ
Map message handler to topic in communication.xml
Map consumer to queue in queue_consumer.xml
Run consumer(s):
![Page 25: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/25.jpg)
Communication & Queue Configurations
We achieved: Non-Blocking request, response to Facebook sent immediately Scalability handled by Queue Availability handled by QueueCommunication vs Queue:• Communication Framework is an abstraction around
publisher/subscriber. It can be implemented:– with database and HTTP requests instead (webhooks)– in-memory (observers)
• Queue is a Transport layer for Communication– configuration of RabbitMQ adapter and topology
![Page 26: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/26.jpg)
API OUT Using RabbitMQ
![Page 27: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/27.jpg)
Goal: Magento Sends Messages to RabbitMQ
• Scripts: https://github.com/vrann/http-rabbitmq-writer
Messenger
API
callback.php
response.php
![Page 28: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/28.jpg)
Before: Sender Interface Using HTTP Request
![Page 29: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/29.jpg)
Now: Sender Interface Using RabbitMQReplace preference for MessageSenderInterface in di.xml, Add “Remote” suffix
Interface implementation will be auto-generated:
![Page 30: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/30.jpg)
Publisher & Topology
queue_publisher.xml maps generated topic to the exchange
queue_topology.xml configures exchange to queue bindings
• Prior to Magento EE 2.2 these config are in queue.xml
![Page 31: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/31.jpg)
Wrap Up
• We covered:– Reasons behind Magento Web API data structures– Reasons to use queues– Switch from Web API to the RabbitMQ – Code generation of API OUT for RabbitMQ– Communication framework vs Queue framework– Separation of publishers, consumers, topology in 2.2– Input Message Handling– Facebook bots!
• https://github.com/vrann/facebook-chatbot• https://github.com/vrann/http-rabbitmq-writer• https://github.com/vrann/magebot
![Page 32: Magento Live Australia 2016 Facebook Chatbot for Magento](https://reader038.vdocuments.us/reader038/viewer/2022100802/5871af101a28abda6a8b638d/html5/thumbnails/32.jpg)
Q&AWrite me @vrann (twitter, github)[email protected]