Share feedback, ideas and get community help

Updated 10 months ago

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)

Plain Text
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.
B
M
t
6 comments
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!
Thanks @Baptiste

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
Have you ever tried looping a block? For example an image block with an array that contains 3 images? I tried and viewer did freeze, I needed to restart it.
The IDs should be unique on the same typebot. It should be fine if there are similar IDs on other linked typebots.
Provide an example (in a new post), I can help you πŸ™‚
Add a reply
Sign up and join the conversation on Discord