> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # Workflow\.sleep() `.sleep()` 方法會暫停執行指定的毫秒數。延遲時間可接受靜態數值,亦可接受在執行階段決定延遲時間的 callback function。 ## 使用範例 ```typescript workflow.sleep(5000) ``` ## 參數 **milliseconds** (`number | ((context: { inputData: any }) => number | Promise)`): 暫停執行的毫秒數,或傳回延遲時間的 callback function ## 傳回值 **workflow** (`Workflow`): 用於串連方法的 Workflow 實例 ## 延伸使用範例 ```typescript import { createWorkflow, createStep } from "@mastra/core/workflows"; const step1 = createStep({...}); const step2 = createStep({...}); export const testWorkflow = createWorkflow({...}) .then(step1) .sleep(async ({ inputData }) => { const { delayInMs } = inputData; return delayInMs; }) .then(step2) .commit(); ```