Create a chatbot interacting with Reactor

Reactor was made to serve each type of front-end applications, who want to handle multistep service manipulation carts. The interfaces have sophisticated data structure to minimise the API requests, like an add operation can respond with the new CurrentPortfolio state of Reactor transaction together with the update AvailableProductOfferings list. Other it is fine for many applications, others require simplified interfaces having predefined standard response structures. One example is chatbot.

You can test a demo implementation, starting a chat on Messenger with Reactor user (company account), which you can identify by its picture:

Using Chatfuel a simple bot was created to show how a chatbot can be integrated with Reactor. This article shows the blocks would be created to interact with Reactor if you would like to create your own selling capable chatbot without including all business logics into the bot itself. The chatbot is not so matured from interpretation prospective, you can test it with offer, more, thank or status words as a basic and you cannot do order there.

Block: Automatic transaction opening

The first step was to create a block called Automatic transaction opening, which is responsible to open Reactor transaction at the start of chat, but latest before the first response will be needed, which comes from Reactor. Be aware at each block steps, to define attibutes with the same case sensitive names, getting the same values as the pictures show!

The apiKey is the identifier of the tenant created for the given bot. The tenant contains the products may be offered and the rules control the business logics about the products. The responseType and listType attributes must have to contain the values shown on the picture. Helping your implementation, here are the attributes ready to copy: transactionID, apiKey (the value is b98c7dc1-f105-453b-9be5-d7c2293c5fd5), responseType (value is both) and listType (value is list).

The next step is the JSON API.

The real URL is: http://chatbotapi.lon-2.paas.massivegrid.net/cbOpenTransaction

Modification of Block: Welcome Message

The Welcome Message block was modified by adding a Go to Block element.

Block: ReadProductOfferings

The next block should be created is another JSON API, collecting the list of offered products.

The URL is: http:/chatbotapi.lon-2.massivegrid.net/cbGetAvailableProductOfferings

This API uses the listType attribute, and based on the value two kind of answers are possible: list and carousel style web content to display in the chat. The interface on Reactor side handles the Messenger data strucutre and specialities, like list must contain maximum 4 and the carousel is maximum 10 elements.

Block: GetProductOfferingList

This block is setting the listType attribute to value list, and goes to ReadProductOfferings block to invoke the getter API.

Block: GetProductOfferingsCarousel 

Very the same as GetProductOfferingList, but it sets listType to value generic.

There is also an interface to query the current portfolio, which is accessible at http://chatbotapi.lon-2.paas.massivegrid.net/cbGetCurrentPortfolio

It may happen, that there are only one item in the response, then you should use list listType:generic, because Messenger does not display "list" with one element. On production environments this is handled by Reactor interface by default.

Having great time of concept implementations!

Log in to comment

Architect Archers

Architect Archers are Enterprise Architect professionals and mentors.

Our mission is to build Your Archers team while defining, aiming and hit your Enterprise Targets.

© 2017 Architect Archers