> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # Workflow\.sleep() `.sleep()` 方法會暫停執行指定的毫秒數。它可接受固定數字,或透過回呼函式在執行階段決定延遲時間。 ## 使用範例 ```typescript workflow.sleep(5000) ``` ## 參數 **milliseconds** (`number | ((context: { inputData: any }) => number | Promise)`): 要暫停執行的毫秒數,或回傳延遲時間的回呼函式 ## 回傳值 **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(); ```