Guide
MOI
Handle User Actions
12min
filter selection as an example, let us assume that the shopper was presented different sizes as options based on the earlier response provided by the moi backend "filter" { "settings" { "label" "please select a size ", "key" "size", "chatformat" "$value$ please!", "chatformatempty" "any size would do!" }, "options" \[{ "name" "s", "value" "size\ s", "selected" "false", "count" "31" }, { "name" "m", "value" "size\ m", "selected" "false", "count" "30" }, ], "note" null } when a shopper selects a filter option, for example, size "s", we expect a request such as the following to be submitted to the moi backend { "context" { }, "message" "s please!", "filter" { "value" "size\ s" } } please note how the message is submitted and the filter element with the value " size\ s" is submitted this is the value of the option that was sent in the original response if customer chooses two sizes “s” and “m”, the request for the same should look like the following { "context" { }, "message" "s and m please!", "filter" { "value" "size\ s;size\ m" } } please note how the value element inside the filter element now has two semicolon separated values product questions this particular option requires a special way of handling when a shopper clicks on this option, in our current (default) interface we open a separate tab, where we allow shoppers to ask questions about the respective product (see below) within this new tab, now when a shopper asks a question, a request such as the following should be made request { "context" { "sessionid" "\<sessionid>", "klevuapikey" "\<store's api key>", "url" "\<url of the product>", "productid" "39941324767325", "mode" "product specific question" }, "message" "what is the material?" } here, as can be seen, we have included three more parameters in the context as well as the shopper's question as message parameter description url the respective product's url productid the respective product's id mode must have the value " product specific question" message the customers question note must be sent outside of the context clause response the moi backend produces a standard response as it does for any other requests { "data" \[{ "context" { "mode" "product specific question", "productid" "39941324767325", "url" "\<url of the product>", "sessionid" "\<sessionid>", "klevuapikey" "\<store's api key>" } }, { "message" { "id" "627cbfb7 c239 4b45 93b0 1f45b3c41037", "type" "text", "value" "the uptown messenger purse is made of faux leather ", "note" null, "explain" null, "collectfeedback" true } }, ] } product click it could be as easy as taking customers to the respective product url, however, the moi backend needs to know the products that the shoppers are clicking on to collect analytics events and provide personalized search experience reports on conversions that were driven by the moi application for this reason, when a shopper clicks on a product , we ask you to submit the following request request { "context" { "sessionid" "\<sessionid>", "klevuapikey" "\<store's api key>" }, "product" { "id" "\<id of the product>", "intent" "redirect", "context" { "url" "\<url of the product>" } } } response { "data" \[{ "context" { "sessionid" "\<sessionid>", "klevuapikey" "\<store's api key>" } }, { "genericoptions" { } }, { "actions" { "actions" \[{ "type" "redirecttourl", "context" { "link" "\<url of a page / product>" } }] } } ] } feedback it is important to get shopper feedback on the responses the moi engine produces for example, not integrated in moi but in another application of ours, currently, we show the thumbs up and down as below feedback needed every message we return would have an id associated with it and an element called collectfeedback with its value either set to " true" or " false" if it is set to " true" , we request you to collect feedback from the shopper { "message" { "id" "6aed823a 1ecc 457a 8d60 d32972408d78", "type" "text", "value" "i am your shopping assistant how can i help you?", "note" null, "explain" null, "collectfeedback" false } }, once the feedback is collected, it can be sent as the following request send feedback important the endpoint to submit feedback is different the messageid here must be the same as the id of the message sent in the response the value of the thumbs parameter must be either " up" or " down" post https //moi ai ksearchnet com/chat/feedback https //moi ai ksearchnet com/chat/feedback { "context" { }, "feedback" { "messageid" "a75715e0 70d7 4741 b8b2 06710e6b36bb", "thumbs" "down" } }