How to get all flows and nodes for a bot via API


I’m working on a hook ‘after_bot_mount’.
I need to know the list of all flows and all nodes within these flows.

I’m wordering if these functions are already existing.

I can’t find anything except the ui-studio api /flows.
Is there a simple API call or any specific function that I could use?

Thank you !

Hi Youstie,

You can list all flow files using the Ghost Content SDK:

Here is an example of listing flows.

// Get ghost content object for bot
const botId = 'mybotid'
const ghost = await bp.ghost.forBot(botId)
// Get all flows and filter skill flows
const flows = (await ghost.directoryListing('flows', '*.json')).filter( flowFileName => !flowFileName.startsWith('skills/'))

for (const flowFileName of flows) {
    const flowFile = await ghost.readFileAsObject('flows', flowFileName)
    // Do what you want with the flowFile

Hope this helps you