Calling Children Flows

Learn how to effectively use the Chatflow Tool and the Custom Tool


One of the powerful features of Flowise is that you can turn flows into tools. For example, having a main flow to orchestrate which/when to use the necessary tools. And each tool is designed to perform a niece/specific thing.

This offers a few benefits:

  • Each children flow as tool will execute on its own, with separate memory to allow cleaner output

  • Aggregating detailed outputs from each children flow to a final agent, often results in higher quality output

You can achieve this by using the following tools:

  • Chatflow Tool

  • Custom Tool

Chatflow Tool

  1. Have a chatflow ready. In this case, we create a Chain of Thought chatflow that can go through multiple chainings.

  1. Create another chatflow with Tool Agent + Chatflow Tool. Select the chatflow you want to call from the tool. In this case, it was Chain of Thought chatflow. Give it a name, and an appropriate description to let LLM knows when to use this tool:

  1. Test it out!

  1. From the response, you can see the input and output from the Chatflow Tool:

Custom Tool

With the same example as above, we are going to create a custom tool that will calls the Prediction API of the Chain of Thought chatflow.

  1. Create a new tool:

Tool NameTool Description

ideas_flow

Use this tool when you need to achieve certain objective

Input Schema:

PropertyTypeDescriptionRequired

input

string

input question

Javascript Function of the tool:

const fetch = require('node-fetch');
const url = 'http://localhost:3000/api/v1/prediction/<chatflow-id>'; // replace with specific chatflow id

const body = {
	"question": $input
};

const options = {
	method: 'POST',
	headers: {
		'Content-Type': 'application/json'
	},
	body: JSON.stringify(body)
};

try {
	const response = await fetch(url, options);
	const resp = await response.json();
	return resp.text;
} catch (error) {
	console.error(error);
	return '';
}
  1. Create a Tool Agent + Custom Tool. Specify the tool we've created in Step 1 in the Custom Tool.

  1. From the response, you can see the input and output from the Custom Tool:

Conclusion

In this example, we have successfully demonstrate 2 ways of turning other chatflows into tools, via Chatflow Tool and Custom Tool. Both are using the same code logic under the hood.

Last updated