Advice on how to implement dynamic questions

Hello

I have an api that I can call in a chat flow. The response from this api is like this (in typescript)

export type Questions = {
    data:  Datum[];
    error: null;
}

export type Datum = {
    question_id:        number;
    parent_question_id?: number | null;
    title:              string;
    sub_title?:          null;
    description?:        null;
    body?:               string;
    answer_type:        AnswerType;
    options:            Option[];
}

export type AnswerType = "multiple_choice";

export type Option = {
    option_id:   number;
    option_text: string;
}

Basically, its an array of questions that have multi choice options.

My first thought was that I would need write a loop that has a condition based on the length of the array.

Then I was thinking maybe its easier to dynamically generate the entire chat flow.
Was this page helpful?