...
Table of Contents | ||
---|---|---|
|
Partial survey flow
This document shows how to configure your survey to capture the data of a partially completed survey.
The following image shows the sample flow. The nodes that are used in this sample flow are explained in the following sections.
...
Create a dynamic schema
The first step is to create a dynamic schema to store the survey information.
...
Get survey ID and session ID
Once a survey is triggered, the Survey ID and the Session ID will be stored in Dynamic Data.
From the project side menu, select Reporting > Data
Select the Partial-Survey Schema from the schema drop-down.
Select the document from the list.
You can see the Survey ID and the Session ID.
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.
Code Block |
---|
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.
...
Set partial-survey data
This function node constructs the survey info such that the survey starts from where the user left off.
Code Block |
---|
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.
Code Block |
---|
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.
...
Attachments | ||||||||
---|---|---|---|---|---|---|---|---|
|
Related Articles
Filter by label (Content by label) | ||||||||
---|---|---|---|---|---|---|---|---|
|