Creating Flows, Choices, Builtin and Skills Programmatically


I am currently working with a wealth of JSON data and I want to write a converter that will take my proprietary JSON structure and transform it into usable Botpress JSON programmatically. I have been looking at the structure of the different areas in the generated directory and believe this is possible; however, I have a few questions about the process. I am using Botpress 10.5 if that makes a difference.

Does Botpress have any restrictions in place that would prevent me from dynamically creating Builtin IDs and linking them to different choices?

If I do not care about using the admin UI do I still need to generate ui.json files for each flow?

Is there a general structure guideline I can look at that would help me see the big picture of how each file is linked together besides just looking at existing JSON code in the Skills or Router directories?

Is there any “data dictionary” on the JSON files themselves. For example, is there documentation that could tell me what Choice file properties are required and the general structure of the Builtin, Choices, and Flow JSON files?

Thank you in advance for your help

@sylvain @alex is this possible?

I believe this is possible, but you may need to force botpress refresh info on the flows.
I didn’t see any guidelines on JSON structures, since this was considered as internal schema for botpress.

Do you know if those internal schemas could be posted by someone who worked on them since they aren’t in the official documentation? I think this would be a valuable tool for future botpress developers that want to load in large amounts of data.

Hey Austin,

You could certainly push your own JSON files and it should work if you follow the same format. Note that the schemas as versioned, so if we’re to make changes we will increment the version so your schema will keep working on the same major version of the software.

You can have a look at the internal definitions here:

Hope that helps

1 Like

Forgot to say that it’s probably best to use the internal APIs to get/push/update flows, as this will use the right Ghost Driver (disk or db), cleaning the cache and make the dialog engine aware of the new flows.

1 Like

Thank you very much @sylvain this has been very helpful.

1 Like

Hello sylvain, I am trying to create a flow programatically.

i have called the below endpoint

I can able to create a flow using botpress admin UI and it is sending an JSON object into body using post method. Flows are created and working fine.

Now i am trying to create a flow programatically , I took same JSON object and tried to post using postman. New flow is not generating.

My understanding is : I have compared JSON body for flows. seems it is creating an Node ID in each flows.

My Question is : How are you generating Node id in each flows. does it have any logic or is it a random number.

For clarification i am attaching an image.

Kindly clarify how node id is generated. when we create a flow.

The IDs are random; but to create flows programmatically please use the flows http API and send the same payload.

Also make sure you use the same HTTP headers, such as “authorization” and also “content-type” are important.

Thanks for the clarification,

@sylvain, Does botpress has any http API to get cleanFlows list?

What do you mean by cleanFlows? Do you mean a list of all the current flows? If yes, check the GET /flows call when you refresh the flows page in your browser