Ask UI - workflow


Workflows are JavaScript objects that control the process of the entire data flow from SDK API request to UI display.

Access workflow

You can access the (root) workflow as the following:

const workflow = client.ui.ask;

When there are multiple workflows, you can retrieve all of them or by question ID or by parent question ID:

const context = client.ui.asks;

const workflows = context.workflows; // returns an array of workflows
const workflow0 = context.getByQuestionId('...');
const workflow1 = context.getByParentQuestionId('...');

You can also navigate through the question chain:

const nextWorkflow0 = workflow.next; // undefined if there is no follow-up question
const nextWorkflow1 = workflow.getOrCreateNext(); // create a new workflow if absent
const previousWorkflow = workflow.previous; // undefined for the root workflow

Listen to workflow creation:

const context = client.ui.asks;

context.on('create', (workflow) => {
// When a new workflow is created
});

Properties

const questionId = workflow.questionId;
const parentQuestionId = workflow.parentQuestionId;