#Advice on how to implement dynamic questions

1 messages · Page 1 of 1 (latest)

mild rampart
#

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.

craggy trout
#

You should be able to create a loop by "popping" items from a list variable one by one until the list is empty.

But to be honest, it was not made for that so you will struggle with other part of the flow.

#

If you can generate the typebot before, yes using the API to create a new typebot is better I think!

mild rampart
#

Thanks @craggy trout

If you can generate the typebot before, yes using the API to create a new typebot is better I think!
I've got a couple of questions related to this.

  1. I see the json groups and blocks have unique ids. Do these need to be unique across the chat flow, or across all chat flows?
  2. If I was to recursively use the Link to typebot feature, but with different variables, would you see any issues, eg, accurately storing chat state
crystal verge
craggy trout