logo
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.
  1. JS SDK:
    1. javascript
      _1flow.on("surveyDidFinish", (data) => { console.log("Event trigger by 1flow"); console.log(JSON.stringify(data.detail)) /*-----PERFROM ANY ACTION ---*/ });
  1. NPM SDK:
    1. import { oneflow } from 'javascript-1flow-sdk';
      javascript
      oneflow.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"
      javascript
      oneflow.on("surveyDidFinish",(data) => { console.log("Event trigger by 1flow"); console.log(JSON.stringify(data.detail)) /*-----PERFROM ANY ACTION ---*/ })

Demo data structure 1flow callback:

javascript
Example:- { "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