Implementation:Langgenius Dify CreateApp Workflow
Appearance
| Knowledge Sources | Dify |
|---|---|
| Domains | Workflow, DAG, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
The createApp function is the frontend service method responsible for creating new applications in the Dify platform. When the mode parameter is set to AppModeEnum.WORKFLOW or AppModeEnum.ADVANCED_CHAT, the resulting application is a DAG-based workflow that can be visually composed in the Workflow Builder. The function issues a POST request to the /apps endpoint with the application metadata and mode discriminator.
Usage
To create a workflow application:
- Import
createAppfromweb/service/apps.ts. - Pass an object with name (required), mode set to
AppModeEnum.WORKFLOW(for pure DAG) orAppModeEnum.ADVANCED_CHAT(for conversational DAG), and optional fields icon_type, icon, icon_background, description, and config. - The function returns a
Promise<AppDetailResponse>containing the created application's details including its unique id.
Code Reference
Source Location
web/service/apps.ts, lines 23-41.
Signature
export const createApp = ({
name,
icon_type,
icon,
icon_background,
mode,
description,
config,
}: {
name: string
icon_type?: AppIconType
icon?: string
icon_background?: string
mode: AppModeEnum
description?: string
config?: ModelConfig
}): Promise<AppDetailResponse> => {
return post<AppDetailResponse>('apps', {
body: { name, icon_type, icon, icon_background, mode, description, model_config: config },
})
}
Import
import { createApp } from '@/service/apps'
import { AppModeEnum } from '@/types/app'
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string |
Yes | Display name for the new application |
| icon_type | AppIconType |
No | Type of icon (emoji or image) |
| icon | string |
No | Icon value (emoji character or image URL) |
| icon_background | string |
No | Background color for the icon |
| mode | AppModeEnum |
Yes | Application mode; use AppModeEnum.WORKFLOW ('workflow') for DAG pipelines or AppModeEnum.ADVANCED_CHAT ('advanced-chat') for conversational DAG workflows
|
| description | string |
No | Human-readable description of the application |
| config | ModelConfig |
No | Optional model configuration for chat-based modes |
Outputs
| Field | Type | Description |
|---|---|---|
| (return) | Promise<AppDetailResponse> |
Resolves to the full application detail object, including the generated id, name, mode, and other metadata |
Usage Examples
import { createApp } from '@/service/apps'
import { AppModeEnum } from '@/types/app'
// Create a pure DAG workflow application
const workflowApp = await createApp({
name: 'Document Processing Pipeline',
mode: AppModeEnum.WORKFLOW,
description: 'Extracts and transforms document content',
})
// Create a conversational DAG workflow application
const advancedChatApp = await createApp({
name: 'Customer Support Bot',
mode: AppModeEnum.ADVANCED_CHAT,
description: 'Multi-step chat workflow with knowledge retrieval',
})
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment