Guide
MOI

Initialization

3min

Initializing a Session

When a shopper starts a chat session the first time, he or she will not have any sessionId assigned to him/her.  At this time, a message with the Klevu API key should be sent to the MOI backend.  If the API key is valid, the backend in its response will return a sessionId for this shopper and a welcome message to be shown to the shopper.

Request:

JSON


Response:

JSON


 JSON Response Contents 

The initialization respose contains the following datapoints:

context

Parameter

Description

sessionId

The sessionId assigned to the current user and should be used for any subsequent interactions by this user. 

klevuApiKey

The Klevu API key used for the session



message: there can be one or more of this in a single request. When rendering messages on the front, please show them in the order they are provided in the response.

Every message has the following members:

Parameter

Description

id

Every message is assigned a unique id.  This is used when submitting shopper’s feedback for this particular message. We will see an example of the same a bit later in the document. 

type

In the current version, the value of this remains as "text".

value

The message you want to show to the shopper.  The value here is usually a plain text but can also contain URLs and therefore the respective html anchors in it.

note

This is like a fine print or an instruction or a general note that you may want to show as a fine print to the current message.

explain

Why the system has produced the answer it has, the explanation of the same is provided in this element. It details the reasoning the backend system has followed. In our UIs we show them behind the info icon.

collectFeedback

If set to "true", this is an instruction to the frontend that feedback should be collected for this particular message.



Updated 04 Mar 2024
Doc contributor
Did this page help you?