Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This document shows how to configure and capture the data of a partially completed survey questionnaire using the flow studio.

This flow allows you to save a conversation of the user if it is not completed.
You can send him a link with the sessionid and/or flowid to prompt him to complete the partially finished survey.

Experience Manager

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

Dynamic schema

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

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

The following sample schema is a template that allows you to save data of a partially completed flow studio.

...

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

Sample URL (with flowid and sessionid): https://yourdomain.orbita.cloud:8443/oeapi/bot/myfirstchatbot?surveyIDflowId=5c1190a401bc681000d6698b&sessionId=:5a158f6422d2ab0f0036df81:c6388e6b-c0f7-4b0e-828f-2c665557a4cf

Append ?flowId='####'&sessionId='####' at the end of your chatbot URL to launch the partial flow.

Get survey ID and session ID

Once a survey is triggered, the Survey ID and the Session ID will be stored in Dynamic Data. You access the saved data in the data section of the side menu.

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

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

    Image RemovedImage Added
  3. Select the document from the list.

    Image RemovedImage Added

  4. You can see the Survey flow_ID and the Session_ID in the document.

    Image RemovedImage Added

Experience Designer

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

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

...

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 flowID and the sessionID given in the URL.

Code Block
var _ = global.get('lodash');
msg.payload.originalRequest.data.flowId=msg.req.query.flowId;
//to support the session ID from query Param

if (msg.req.query.sessionId){
    msg.payload.sessionId = msg.req.query.sessionId;
}
else {
    msg.payload.sessionId = msg.payload.sessionId;
}
var querySessionId = _.

...

get(msg, 'payload.sessionId', null);
if (querySessionId) {
    _.set(msg, 'payload.originalRequest.data.sessionId', querySessionId);
}

Function nodes

There are 3 function nodes used in the flow.

Select Flow studio

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

Code Block
var var _  = global global.get('lodash');


if(_.get(msg, 'payload.originalDetectIntentRequest.payload.flowId', undefined)){
    msg.payload.surveyId flowId =  _.get(msg,  'payload.originalDetectIntentRequest.payload.surveyIDflowId',  '');
var sessionId = }
else{
    msg.payload.flowId = ''; // Place your flow id here 
}
var sessionId = _.get(msg,  'payload.originalDetectIntentRequest.payload.sessionId', null null)

if if (sessionId){
        _.set(msg,  'payload.sessionId', 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.

...


return msg;

Set partial Flow studio data

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

Code Block
var _ = global.get('lodash');

var surveyContentflowContent = _.get(msg, 'data.dynamicData.result.0.surveydataflowdata', null);

if (surveyContent && surveyContent.surveyInfoflowContent) {
  _.set(msg, 'orbita.session.surveyInfoflowInfo', surveyContent.surveyInfo)  flowContent)   
}

return msg;

Save partial

...

Flow studio data

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

Code Block
var _ = global.get('lodash');
var surveyDataflowInfo = {
    answers: _.get(msg, 'payload.answers', null),
    survey: _.get(msg, 'payload.orbita.survey', null),
    surveyInfo: _.get(msg, 'payload.session.attributes.orbitaSession.surveyInfo', null)
}flowInfo;

var surveyidpartialFlowStudio = _.get(msg, 'orbita.session.surveyInfo.surveyId', null);
var partialSurvey = {
    surveydata: surveyData,
    surveyid: surveyid
} {
    flowdata: flowInfo,
    flowid: flowInfo.flowId,
    sessionid: msg.payload.originalDetectIntentRequest.payload.sessionId
}

_.set(msg, 'payload.data', partialSurveypartialFlowStudio);

//If survey the flow studio flow is completed, we need to delete the partial flow studio surveydata from dynamic data.
if (_.get(msg, 'payload.orbita.session.survey.completedSurveyQuestions', null)flowInfo.state == 'DONE') {
       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.

Code Block
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);
}

...

Dynamic Data Manager nodes

Dynamic Data Manager (Get)

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

Ensure that you select the correct schema in the model field of the node.

...

Dynamic Data Manager (Upsert)

This node will search for the sessionid in the dynamic data;

  • if sessionid is found, it updates the document with the new data.

  • if sessionid is not found, it will create a new document with the new data.

...

Dynamic Data Manager (Delete)

This node will search for the sessionid from the dynamic data and deletes that document.

...

Attachments
previewfalse
uploadfalse
oldfalse
patterns.*json

...

Filter by label (Content by label)
experience-designer flow-studio
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@130ffshowSpacefalse
sortmodified
typeshowSpacepagefalse
reversetruelabels
typepage
cqllabel in ( "experience-designer" , "flow-studio" ) and type = "page" and space = "OCS"

...

hiddentrue
labelsexperience-designer flow-studio