Quick Start
This document will help you quickly get started with FlowGram Runtime, including environment preparation, installation, configuration, creating and running workflows. Through this guide, you'll be able to set up your workflow runtime environment and run your first workflow example in a short time.
Getting the Code
Since FlowGram Runtime is positioned as a demo rather than an SDK and will not be published as an npm package, you need to follow these steps to obtain and use it:
Method 1: Fork the Repository (Recommended)
- Visit the FlowGram Runtime repository
- Click the "Fork" button to create your own copy of the repository
- Clone your forked repository to your local machine
Method 2: Direct Clone
If you just want to try it out without submitting changes, you can clone the original repository directly:
git clone git clone git@github.com:bytedance/flowgram.ai.git
cd flowgram.ai
Environment Preparation
Before you start using FlowGram Runtime, please ensure your development environment meets the following requirements:
- Node.js: Version 18.x or higher (LTS version recommended)
nvm install lts/hydrogen
nvm alias default lts/hydrogen # set default node version
nvm use lts/hydrogen
- Package Manager: pnpm 9+ and rush 5+
npm i -g pnpm@9.12.0 @microsoft/rush@5.140.1
Installing Dependencies and Project Setup
After obtaining the code, you need to install dependencies and perform basic setup:
- Install Project Dependencies
- Build the Project
Starting the Service
- Navigate to Runtime Directory
cd packages/runtime/nodejs
- Start the nodejs Server
If everything is working correctly, you should see the following output in the console:
> Listen Port: 4000
> Server Address: http://localhost:4000
> API Docs: http://localhost:4000/docs
- Verify the Service
You can test the service using cURL:
curl --location 'http://localhost:4000/api/task/run' \
--header 'Content-Type: application/json' \
--data '{
"inputs": {
"test_input": "Hello FlowGram!"
},
"schema": "{\"nodes\":[{\"id\":\"start_0\",\"type\":\"start\",\"meta\":{\"position\":{\"x\":180,\"y\":0}},\"data\":{\"title\":\"Start\",\"outputs\":{\"type\":\"object\",\"properties\":{\"test_input\":{\"key\":4,\"name\":\"test_input\",\"isPropertyRequired\":true,\"type\":\"string\",\"extra\":{\"index\":0}}},\"required\":[\"test_input\"]}}},{\"id\":\"end_0\",\"type\":\"end\",\"meta\":{\"position\":{\"x\":640,\"y\":0}},\"data\":{\"title\":\"End\",\"inputsValues\":{\"test_output\":{\"type\":\"ref\",\"content\":[\"start_0\",\"test_input\"]}},\"inputs\":{\"type\":\"object\",\"properties\":{\"test_output\":{\"type\":\"string\"}}}}}],\"edges\":[{\"sourceNodeID\":\"start_0\",\"targetNodeID\":\"end_0\"}]}"
}'
You should see the following output in the command line where the service is running:
> POST TaskRun - taskID: xxxx-xxxx-xxxx-xxxx
{ test_input: 'Hello FlowGram!' }
> LOG Task finished: xxxx-xxxx-xxxx-xxxx
{ test_output: 'Hello FlowGram!' }
Compiling the Service
- Enter the Runtime Directory
cd packages/runtime/nodejs
- Compile the Service
- Start the nodejs Server