How to Invoke Coze Workflows Using Tools
Coze is a powerful workflow automation tool used to create various automated tasks. ConsoleX supports invoking Coze workflows through tools, thereby expanding the capabilities of large models and enabling them to handle more complex tasks.
Basic Steps
Create a workflow in Coze and publish it, starting with the Start node and ending with the End node. The URL for invoking workflows on Coze.com is standardized as
https://api.coze.com/v1/workflows/run
. To differentiate between workflows, you need to append the workflow ID to the workflow invocation URL in ConsoleX, formatted as:https://api.coze.com/v1/workflows/run#{workflow_id}
. The End node needs to be set to response text mode and should be assembled into a JSON object to serve as the tool's return result. The field values in this JSON object can be set using variables used within the workflow.In ConsoleX AI, click on Tools and then click Add Tool. In the JSON Schema description for tool definition, enter the JSON Schema description corresponding to the input parameters of the Coze workflow. The format is consistent with OpenAI's standard tool description format. You can refer to examples or use AI assistance to generate it.
Next, click to choose to initiate a tool invocation and select the POST method. Then, select Coze for the tool function interface type and enter the Coze workflow invocation URL (including the workflow ID) into the tool function interface URL. Choose an appropriate return content processing method based on your needs, then click Save, and the tool corresponding to the Coze workflow will be created.
Finally, add the tool to the conversation as needed. The large model will automatically invoke the Coze workflow based on the tool's description and input parameters, just like other tools, and return the results.
Notes
- The tool's JSON Schema description must correspond to the input parameters of the Coze workflow; otherwise, the large model cannot correctly invoke the Coze workflow. You can view the debug information of the workflow invocation in the run history of Coze.
- Workflows in Coze must be published to be invoked and cannot be invoked if unpublished.
- The workflow invocation URLs for the international and Chinese versions of Coze are different:
- International version:
https://api.coze.com/v1/workflows/run
- Chinese version:
https://api.coze.cn/v1/workflows/run
- International version:
Frequently Asked Questions
Setting Auth Token Verification for Workflows
All workflows in Coze use a unified token for verification. You need to create a token in Authorization and set the appropriate permissions. Please note that Coze tokens currently have an expiration period, with a maximum of 30 days of use, so regular updates are necessary.