{"record":{"id":"7cf6e3866654020e","repo":"windmill-labs/windmill","slug":"you-can-t-use-request-interactive-slack-approval","errorCode":null,"errorMessage":"You can't use 'request_interactive_slack_approval' function in a standalone script or flow step preview. Please use it in a flow or a flow preview.","messagePattern":"You can't use 'request_interactive_slack_approval' function in a standalone script or flow step preview\\. Please use it in a flow or a flow preview\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"python-client/wmill/wmill/client.py","lineNumber":1373,"sourceCode":"        **Usage Example:**\n            >>> client.request_interactive_slack_approval(\n            ...     slack_resource_path=\"/u/alex/my_slack_resource\",\n            ...     channel_id=\"admins-slack-channel\",\n            ...     message=\"Please approve this request\",\n            ...     approver=\"approver123\",\n            ...     default_args_json={\"key1\": \"value1\", \"key2\": 42},\n            ...     dynamic_enums_json={\"foo\": [\"choice1\", \"choice2\"], \"bar\": [\"optionA\", \"optionB\"]},\n            ... )\n\n        **Notes:**\n        - This function must be executed within a Windmill flow or flow preview.\n        - The function checks for required environment variables (`WM_FLOW_JOB_ID`, `WM_FLOW_STEP_ID`) to ensure it is run in the appropriate context.\n        \"\"\"\n        workspace = self.workspace\n        flow_job_id = os.environ.get(\"WM_FLOW_JOB_ID\")\n\n        if not flow_job_id:\n            raise Exception(\n                \"You can't use 'request_interactive_slack_approval' function in a standalone script or flow step preview. Please use it in a flow or a flow preview.\"\n            )\n\n        # Only include non-empty parameters\n        params = {}\n        if message:\n            params[\"message\"] = message\n        if approver:\n            params[\"approver\"] = approver\n        if slack_resource_path:\n            params[\"slack_resource_path\"] = slack_resource_path\n        if channel_id:\n            params[\"channel_id\"] = channel_id\n        if os.environ.get(\"WM_FLOW_STEP_ID\"):\n            params[\"flow_step_id\"] = os.environ.get(\"WM_FLOW_STEP_ID\")\n        if default_args_json:\n            params[\"default_args_json\"] = json.dumps(default_args_json)\n        if dynamic_enums_json:","sourceCodeStart":1355,"sourceCodeEnd":1391,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/python-client/wmill/wmill/client.py#L1355-L1391","documentation":"request_interactive_slack_approval is flow-only: it requires WM_FLOW_JOB_ID (and WM_FLOW_STEP_ID), which Windmill sets only when executing a step inside a real flow run. Standalone scripts and flow step previews lack these variables, so no approval job could be created and the library refuses early with this explicit message.","triggerScenarios":"Calling client.request_interactive_slack_approval(...) from a script run directly (Run button on the script editor), from a scheduled/standalone job, or from a flow STEP preview instead of a full flow run/preview.","commonSituations":"Testing a Slack-approval script standalone before wiring it into a flow; migrating approval logic out of a flow into a plain script; running a single step in isolation via step preview.","solutions":["Move the call into a flow step and run the whole flow","Use full flow preview instead of step preview","For standalone scenarios, poll Slack or use webhooks instead of this function","Keep the approval in the flow and extract only pure helpers into the script"],"exampleFix":"// before\n# script executed standalone\nwm.get_client().request_interactive_slack_approval(\"Approve?\")\n// after\n# inside a step of a flow run / full flow preview\napproval = wm.get_client().request_interactive_slack_approval(\"Approve?\")","handlingStrategy":"validation","validationCode":"import os\ndef can_request_slack_approval() -> bool:\n    return bool(os.environ.get(\"WM_FLOW_JOB_ID\"))","typeGuard":null,"tryCatchPattern":"try:\n    approval = client.request_interactive_slack_approval(\"Approve?\")\nexcept Exception as e:\n    if \"standalone script\" in str(e):\n        raise RuntimeError(\"Move this call into a flow step and run the full flow\") from e\n    raise","preventionTips":["Keep approval calls in flow steps, never in standalone scripts","Use full flow preview, not step preview, when testing approvals","Guard the call site with an os.environ check on WM_FLOW_JOB_ID","Mark scripts using this function as flow-only in docs/naming"],"tags":["flow","slack","approval","context","environment-variable"],"backgroundTag":"api-called-outside-supported-context","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}