Skip to main content

Chatflows

This guide covers the management and usage of chatflows in the Flowise service.

Chatflows Overview

Chatflows are the core building blocks in Flowise that allow you to create conversational AI workflows using a visual builder. Each chatflow represents a complete conversation flow that can be embedded in your applications or accessed via API.

Chatflow Endpoints

List Chatflows

Retrieve a list of all available chatflows.
GET /api/v1/chatflows

curl "https://flowise.moodmnky.com/api/v1/chatflows" \
  -H "x-api-key: your_api_key"
Response:
{
  "chatflows": [
    {
      "id": "chatflow-1234",
      "name": "Customer Support Bot",
      "category": "Support",
      "deployed": true,
      "isPublic": true,
      "updatedAt": "2024-03-15T12:30:45Z"
    },
    {
      "id": "chatflow-5678",
      "name": "Product Recommender",
      "category": "Sales",
      "deployed": true,
      "isPublic": false,
      "updatedAt": "2024-03-20T09:15:22Z"
    }
  ]
}

Get Chatflow

Retrieve a specific chatflow by ID.
GET /api/v1/chatflows/{chatflowId}

curl "https://flowise.moodmnky.com/api/v1/chatflows/chatflow-1234" \
  -H "x-api-key: your_api_key"
Response:
{
  "id": "chatflow-1234",
  "name": "Customer Support Bot",
  "deployed": true,
  "isPublic": true,
  "category": "Support",
  "updatedAt": "2024-03-15T12:30:45Z",
  "nodes": [...],
  "edges": [...],
  "variables": [...]
}

Create Chatflow

Create a new chatflow.
POST /api/v1/chatflows

curl -X POST "https://flowise.moodmnky.com/api/v1/chatflows" \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New Support Bot",
    "category": "Support",
    "isPublic": true,
    "nodes": [...],
    "edges": [...]
  }'
Response:
{
  "id": "chatflow-9876",
  "name": "New Support Bot",
  "category": "Support",
  "deployed": false,
  "isPublic": true,
  "createdAt": "2024-04-01T10:25:12Z",
  "updatedAt": "2024-04-01T10:25:12Z"
}

Update Chatflow

Update an existing chatflow.
PUT /api/v1/chatflows/{chatflowId}

curl -X PUT "https://flowise.moodmnky.com/api/v1/chatflows/chatflow-9876" \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Support Bot",
    "category": "Support",
    "nodes": [...],
    "edges": [...]
  }'

Delete Chatflow

Delete a chatflow.
DELETE /api/v1/chatflows/{chatflowId}

curl -X DELETE "https://flowise.moodmnky.com/api/v1/chatflows/chatflow-9876" \
  -H "x-api-key: your_api_key"

Deploy Chatflow

Deploy a chatflow to make it available for use.
POST /api/v1/chatflows/{chatflowId}/deploy

curl -X POST "https://flowise.moodmnky.com/api/v1/chatflows/chatflow-9876/deploy" \
  -H "x-api-key: your_api_key"
Response:
{
  "id": "chatflow-9876",
  "deployed": true,
  "updatedAt": "2024-04-01T10:30:45Z"
}

Undeploy Chatflow

Undeploy a chatflow to make it unavailable for use.
POST /api/v1/chatflows/{chatflowId}/undeploy

curl -X POST "https://flowise.moodmnky.com/api/v1/chatflows/chatflow-9876/undeploy" \
  -H "x-api-key: your_api_key"
Response:
{
  "id": "chatflow-9876",
  "deployed": false,
  "updatedAt": "2024-04-01T10:35:12Z"
}

Chatflow Parameters

Chatflow Object

FieldTypeDescription
idstringUnique identifier for the chatflow
namestringName of the chatflow
categorystringCategory for organization purposes
deployedbooleanWhether the chatflow is deployed and available for use
isPublicbooleanWhether the chatflow is accessible without authentication
nodesarrayArray of node objects that make up the chatflow
edgesarrayArray of edge objects connecting the nodes
variablesarrayArray of variable objects for the chatflow
createdAtstringCreation timestamp
updatedAtstringLast update timestamp

Node Object

FieldTypeDescription
idstringUnique identifier for the node
typestringType of the node (e.g., “textInput”, “llmChain”)
positionobjectX and Y coordinates of the node in the builder
dataobjectConfiguration data for the node

Edge Object

FieldTypeDescription
idstringUnique identifier for the edge
sourcestringID of the source node
targetstringID of the target node
sourceHandlestringOutput handle of the source node
targetHandlestringInput handle of the target node

Usage Examples

List and Filter Chatflows

// List all chatflows
const response = await client.flowise.listChatflows();
console.log(`Found ${response.chatflows.length} chatflows`);

// Filter by category
const supportChatflows = response.chatflows.filter(
  flow => flow.category === "Support"
);
console.log(`Found ${supportChatflows.length} support chatflows`);

// Get only deployed chatflows
const deployedChatflows = response.chatflows.filter(
  flow => flow.deployed === true
);
console.log(`Found ${deployedChatflows.length} deployed chatflows`);

Manage Chatflow Deployment Status

// Deploy a chatflow
async function deployChatflow(chatflowId) {
  try {
    const result = await client.flowise.deployChatflow(chatflowId);
    console.log(`Chatflow ${chatflowId} deployed successfully`);
    return result;
  } catch (error) {
    console.error(`Failed to deploy chatflow: ${error.message}`);
    throw error;
  }
}

// Undeploy a chatflow
async function undeployChatflow(chatflowId) {
  try {
    const result = await client.flowise.undeployChatflow(chatflowId);
    console.log(`Chatflow ${chatflowId} undeployed successfully`);
    return result;
  } catch (error) {
    console.error(`Failed to undeploy chatflow: ${error.message}`);
    throw error;
  }
}

// Toggle deployment status
async function toggleChatflowDeployment(chatflowId) {
  const chatflow = await client.flowise.getChatflow(chatflowId);
  
  if (chatflow.deployed) {
    return await undeployChatflow(chatflowId);
  } else {
    return await deployChatflow(chatflowId);
  }
}

Create and Update Chatflows

// Create a simple chatflow with text input and LLM response
async function createSimpleChatbot(name, category, apiKey) {
  const chatflowData = {
    name,
    category,
    isPublic: true,
    nodes: [
      {
        id: "textInput",
        type: "textInput",
        position: { x: 100, y: 200 },
        data: { text: "Hello! How can I help you today?" }
      },
      {
        id: "llmChain",
        type: "llmChain",
        position: { x: 400, y: 200 },
        data: {
          model: "gpt-3.5-turbo",
          apiKey: apiKey,
          temperature: 0.7
        }
      }
    ],
    edges: [
      {
        id: "edge-1",
        source: "textInput",
        target: "llmChain",
        sourceHandle: "output",
        targetHandle: "input"
      }
    ]
  };
  
  return await client.flowise.createChatflow(chatflowData);
}

// Update chatflow with a new node
async function addMemoryToExistingChatflow(chatflowId) {
  // Get existing chatflow
  const chatflow = await client.flowise.getChatflow(chatflowId);
  
  // Add memory node
  const memoryNode = {
    id: "memoryNode",
    type: "bufferMemory",
    position: { x: 250, y: 300 },
    data: { memoryKey: "chat_history" }
  };
  
  // Add new edges
  const newEdges = [
    {
      id: "edge-to-memory",
      source: "textInput",
      target: "memoryNode",
      sourceHandle: "output",
      targetHandle: "input"
    },
    {
      id: "edge-from-memory",
      source: "memoryNode",
      target: "llmChain",
      sourceHandle: "output",
      targetHandle: "memory"
    }
  ];
  
  // Update chatflow
  chatflow.nodes.push(memoryNode);
  chatflow.edges = [...chatflow.edges, ...newEdges];
  
  return await client.flowise.updateChatflow(chatflowId, chatflow);
}

Best Practices

  1. Chatflow Design
    • Keep chatflows focused on specific use cases
    • Use clear naming conventions
    • Organize with meaningful categories
    • Document the purpose of each chatflow
  2. Deployment Management
    • Test thoroughly before deploying
    • Use deployment toggles for maintenance
    • Monitor usage after deployment
    • Implement versioning for important changes
  3. Security Considerations
    • Use isPublic flag judiciously
    • Implement proper authentication
    • Validate and sanitize user inputs
    • Review node configurations for sensitive data
  4. Performance Optimization
    • Minimize complex node arrangements
    • Use caching where appropriate
    • Monitor response times
    • Implement rate limiting for public chatflows

Advanced Features

Chatflow Variables

You can define variables in your chatflows that can be accessed and modified across nodes.
// Update chatflow to include variables
const chatflowWithVariables = {
  // ... existing chatflow data
  variables: [
    {
      name: "userName",
      type: "string",
      defaultValue: "Guest"
    },
    {
      name: "userPreferences",
      type: "json",
      defaultValue: { language: "en", theme: "light" }
    }
  ]
};

await client.flowise.updateChatflow(chatflowId, chatflowWithVariables);

Chatflow Export and Import

// Export a chatflow
async function exportChatflow(chatflowId) {
  const response = await client.flowise.exportChatflow(chatflowId);
  const json = JSON.stringify(response);
  // Save to file or database
  return json;
}

// Import a chatflow
async function importChatflow(chatflowJson) {
  const chatflowData = JSON.parse(chatflowJson);
  // Modify as needed
  chatflowData.name = `${chatflowData.name} (Imported)`;
  return await client.flowise.createChatflow(chatflowData);
}

Support & Resources