Facebook Messenger and hybris integration
This spring Facebook launched the Messenger platform making it possible for developers to connect their systems with the more than 900 million people around the world who use Messenger.
By default, hybris uses e-mail communication as an only channel to communicate with the customers. However, such channels as Messenger or SMS, are very reasonable for e-commerce, because they make the customer experience nicer and more convenient.
Messenger allows customers to communicate with e-shop in a quick and effective manner, without the delays associated with email.
In my PoC, when a customer makes a purchase, the conversation begins via Messenger. The customer receives a notification, that is delivered instantly. I demonstrate that the automated updates are sent directly to the customers through Messenger, allowing them to track order status and ask questions all in one place. Messenger makes it easy to answer questions about orders and invite your customers to check out related products.
Basically, Messenger can be easily replaced with any other IM software that has appropriate API:
- Google Hangouts,
- and so on.
In the video, I demonstrate the following:
- One-click facebook authentication in hybris:
- At the final step of the checkout flow there is a button “Send to messenger” that enables the notifications via Facebook Messenger:
- Once you click this button, you will receive the message:
- I demonstrate two-way communication. For example, the customer may ask something just by replying to the message. In my demo, that is a message “some question”. The system replies immediately with the message “we received your request, we’re processing it”. Actually the message is delivered to hybris, as a ticket linked to the order and the customer.
- I demonstrate that the ticket is created and this ticket is linked to the order and customer:Actually using tickets for the messages is just an example. For the real system, any other channel/functionality might be leveraged.
- I demonstrate that once the customer agent adds a note to the ticket, the note is delivered back to the customer. Actually, it is just an example. You can use any other events like updating the order status or customer data (or something else that relevant to the order and the customer).
We get a page-scoped user ids from Messenger, so we can’t match existing users with their app-scoped user ids, even though we are using the same FB App for Facebook Login and Messenger Bot Integration. There are some ways to match the messenger users and facebook users, but it is outside the scope of this topic.
Facebook Documentation: The id must be an ID that was retrieved through the Messenger entry points or through theMessenger webhooks (e.g., a person may discover your business in Messenger and start a conversation from there. These IDs are page-scoped IDs (PSID). This means that the IDs are unique for a given page. If you have an existing Facebook Login integration, user IDs are app-scoped and will not work with the Messenger platform.
There are rate limits in Facebook messenger to prevent malicious behavior and poor user experiences. The direct advertising is not welcome. If you send upsale/crosssale offers, you may expect some consequences if the customers make a complaint.
There is a length limit for text messages. The messages must be UTF-8 and have a 320 character limit.
Webhook is a module that serves as a listener for facebook requests. Once the customer sends a message, facebook makes a request to Webhook module. This module sends responses as well.
When customer enables the order updates (by clicking the blue button at the final step of the checkout), the Webhook receives an authorization message from Facebook. Webhook makes a request to hybris for the information about the order and send it back to the user (see the example above, with the thank you message in the chat). In my PoC the order number is injected into the code, but for the real system, this value should be encrypted to avoid receiving information about someone else’s orders.
(this code displays the blue button)
Webhook knows about the recipientID, the unique ID of the user for this particular page. I link this ID with the userID when the customer enables the messaging, so for next messages, this ID will be used to specify the recipient of the message.
© Rauf Aliev, September 2016