Successfully reported this slideshow.
Your SlideShare is downloading. ×

Magento Live Australia 2016 Facebook Chatbot for Magento

Loading in …3

Check these out next

1 of 32 Ad

More Related Content

Slideshows for you (17)


Similar to Magento Live Australia 2016 Facebook Chatbot for Magento (20)


Recently uploaded (20)

Magento Live Australia 2016 Facebook Chatbot for Magento

  1. 1. A Facebook Chat Bot Using Magento 2 Async Processing
  2. 2. Magento 2 Architect Eugene Tulika @vrann
  3. 3. Use-Case: Store With Hand-Picked Books
  4. 4. Niche Customers With Unusual Requests
  5. 5. 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
  6. 6. Facebook Chat Bots • When store Manager cannot handle all communications manually • Facebook webhooks for messages received in the chat • Facebook API for responses
  7. 7. Facebook POSTs Messages to the Callback Callback.php 200 OK
  8. 8. Callback POSTs Response to Facebook API
  9. 9. Understanding the Conversation
  10. 10. How to Convert Messages to Magento API Requests Input Classifier Search catalog by author Title, image url, description
  11. 11. Quadrant of Conversation Parsers Image from
  12. 12. Wit.AI Retrieval Conversation Setup
  13. 13. Conversation Parsing • Do you have a book by Proust? Intent: catalog_search Parameters:  Author: Proust Invoke: catalogSearch(context)
  14. 14. Integration With Magento IN/OUT integration Using Web API
  15. 15. 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)
  16. 16. Callback Makes API Request to Magento Messenger Callback.php API Web API Request Magento POSTs response to Facebook
  17. 17. Web API Service Interface
  18. 18. Magento API Interfaces •
  19. 19. Map Service to the Web API Endpoint
  20. 20. 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!
  21. 21. API IN Using RabbitMQ
  22. 22. Callback Puts Messages to the Queue • Scripts: Messenger API Callback.php Magento POSTs response to Facebook Rabbit MQ
  23. 23. 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):
  24. 24. Communication & Queue Configurations We achieved:  Non-Blocking request, response to Facebook sent immediately  Scalability handled by Queue  Availability handled by Queue Communication 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
  25. 25. API OUT Using RabbitMQ
  26. 26. Goal: Magento Sends Messages to RabbitMQ • Scripts: Messenger API callback.php response.php
  27. 27. Before: Sender Interface Using HTTP Request
  28. 28. Now: Sender Interface Using RabbitMQ Replace preference for MessageSenderInterface in di.xml, Add “Remote” suffix Interface implementation will be auto-generated:
  29. 29. 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
  30. 30. 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! • • •
  31. 31. Q&A Write me @vrann (twitter, github)