Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In the Experience designer, you can design a flow to capture data of a partially completed flow studio. You can use this data to send a link to the chatbot user to complete the partially completed flow studio from where he/she left off.

Experience Manager

To capture the session details, you have to create a dynamic schema.

Create a dynamic schema

The first step is to create a dynamic schema to store the survey information.

Create a dynamic schema with the fields “flowid”, “sessionid”, and “flowdata” name the schema. See, How do I create a schema?

The following sample schema code saves data of a partial flow studio.

{
    "fields": [
        {
            "type": "String",
            "fieldType": "text",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": false
                }
            ],
            "isDefault": false,
            "label": "Session_ID",
            "key": "sessionid"
        },
        {
            "type": "String",
            "fieldType": "text",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": false
                }
            ],
            "isDefault": false,
            "key": "flowid",
            "label": "flow_ID"
        },
        {
            "type": "Object",
            "fieldType": "json",
            "ref": "",
            "options": [],
            "multiple": false,
            "validation": [
                {
                    "required": true
                }
            ],
            "isDefault": false,
            "label": "flow_Data",
            "key": "flowdata"
        }
    ]
}

This schema is used to capture the survey data that the user feeds in. Using this data, the admin user will know if a survey is completed or partially completed.

The admin user then can generate the partial survey URLs and send them to the users for them to continue their surveys.

Sample URL: https://yourdomain.orbita.cloud:8443/oeapi/bot/myfirstchatbot?surveyID=5c1190a401bc681000d6698b&sessionId=:5a158f6422d2ab0f0036df81:c6388e6b-c0f7-4b0e-828f-2c665557a4cf

Get survey ID and session ID

Once a survey is triggered, the Survey ID and the Session ID will be stored in Dynamic Data.

  1. From the project side menu, select Reporting > Data

  2. Select the Partial-Survey Schema from the schema drop-down.

  3. Select the document from the list.

  4. You can see the Survey ID and the Session ID.

Experience Designer

This document shows how to configure the flow in the Experience Designer to capture the data of a partially completed flow studio.

The following image shows the sample flow. The nodes that are used in this sample flow are explained in the following sections.

Select survey

The function node with the name Select Survey fetches the surveyId and the sessionId from the incoming request and pushes the data to Dynamic Data Manager.

var _ = global.get('lodash');
msg.payload.surveyId = _.get(msg, 'payload.originalDetectIntentRequest.payload.surveyID', '');
var sessionId = _.get(msg, 'payload.originalDetectIntentRequest.payload.sessionId', null)
if (sessionId){
    _.set(msg, 'payload.sessionId', sessionId);
}

Dynamic Data Manager (Get)

The Dynamic Data manager fetches the data that matches the surveyId and the sessionId from the database.

Ensure that you select the correct schema.

Set partial-survey data

This function node constructs the survey info such that the survey starts from where the user left off.

var _ = global.get('lodash');
var surveyContent = _.get(msg, 'data.dynamicData.result.0.surveydata', null);
if (surveyContent && surveyContent.surveyInfo) {
 _.set(msg, 'orbita.session.surveyInfo', surveyContent.surveyInfo)   
}
return msg;

Save partial-survey data

This function node contains the logic to save the partial survey to Dynamic Data and delete the completed surveys from Dynamic Data.

var _ = global.get('lodash');
var surveyData = {
    answers: _.get(msg, 'payload.answers', null),
    survey: _.get(msg, 'payload.orbita.survey', null),
    surveyInfo: _.get(msg, 'payload.session.attributes.orbitaSession.surveyInfo', null)
}
var surveyid = _.get(msg, 'orbita.session.surveyInfo.surveyId', null);
var partialSurvey = {
    surveydata: surveyData,
    surveyid: surveyid
}
_.set(msg, 'payload.data', partialSurvey);
//If survey completed, we need to delete the partial survey from dynamic data.
if (_.get(msg, 'payload.orbita.survey.completedSurveyQuestions', null)) {
    return [null, msg]
}
return [msg, null];

Bot Provider V2 node

Place the following code in Bot In Parser of Bot Provider V2 node to let the Bot Provider V2 node process the Survey ID and the Session ID given in the URL.

var _ = global.get('lodash');
msg.payload.originalRequest.data.surveyId=msg.req.query.surveyId;
//to support the session ID from query Param
msg.payload.sessionId = msg.req.query.sessionId || msg.payload.sessionId;
var querySessionId = _.get(msg, 'req.query.sessionId', null);
if (querySessionId) {
    _.set(msg, 'payload.originalRequest.data.sessionId', querySessionId);
}

  • No labels