Frontend Callback feature is released on May 14, 2022.
Introduction
Our SDK provides a callback after closing or submitting the survey by the user. In the below code, you will see how to implement a 1flow survey callback.
- JS SDK:
javascript_1flow.on("surveyDidFinish", (data) => { console.log("Event trigger by 1flow"); console.log(JSON.stringify(data.detail)) /*-----PERFROM ANY ACTION ---*/ });
- NPM SDK:
import { oneflow } from 'javascript-1flow-sdk';
javascriptoneflow.on("surveyDidFinish",(data) => { console.log("Event trigger by 1flow"); console.log(JSON.stringify(data.detail)) /*-----PERFROM ANY ACTION ---*/ })
Next JS project:
import oneflow from "javascript-1flow-sdk/react-next"
javascriptoneflow.on("surveyDidFinish",(data) => { console.log("Event trigger by 1flow"); console.log(JSON.stringify(data.detail)) /*-----PERFROM ANY ACTION ---*/ })
Demo data structure 1flow callback:
javascriptExample:- { "survey_id": "< Hexadecimal string >", //Current survey ID "survey_name": "< String >", // current survey name "trigger_event_name": "< String >", // current survey trigger name "status": "< String >", // last survey status ex:- closed | skipped | finished "screens": [ //current survey questions { "screen_id": "< Hexadecimal string >", // question ID "question_title": "< String >", // question title "question_ans": "< String >", // submitted Ans "question_type": "< String >" // question type }, . . . . ] }
Fields in 1flow callback:
survey_name: string
trigger_event_name: string
status: string
screens: Array