1 | from typing import Optional |
2 | import wmill |
3 |
|
4 | def main( |
5 | slack_resource: str, |
6 | channel_id: str, |
7 | message: Optional[str], |
8 | approver: Optional[str], |
9 | default_args: Optional[dict], |
10 | dynamic_enums: Optional[dict], |
11 | ): |
12 | """ |
13 | Sends an interactive approval request via Slack, allowing optional customization of the message, approver, and form fields. |
14 | |
15 | **[Enterprise Edition Only]** To include form fields in the Slack approval request, use the "Advanced -> Suspend -> Form" functionality. |
16 | Learn more at: https://www.windmill.dev/docs/flows/flow_approval#form |
17 |
|
18 | slack_resource_path (str): The path to the Slack resource in Windmill. |
19 | channel_id (str): The Slack channel ID where the approval request will be sent. |
20 | message (str): Optional custom message to include in the Slack approval request. |
21 | approver (str): Optional user ID or name of the approver for the request. |
22 | default_args_json (dict): Optional dictionary defining or overriding the default arguments for form fields. |
23 | dynamic_enums_json (dict): Optional dictionary overriding the enum default values of enum form fields. |
24 |
|
25 | **Input Example:** |
26 | slack_resource_path="/u/alex/my_slack_resource", |
27 | channel_id="admins-slack-channel", |
28 | message="Please approve this request", |
29 | approver="approver123", |
30 | default_args_json={"key1": "value1", "key2": 42}, |
31 | dynamic_enums_json={"foo": ["choice1", "choice2"], "bar": ["optionA", "optionB"]}, |
32 | """ |
33 | wmill.request_interactive_slack_approval( |
34 | slack_resource, |
35 | channel_id, |
36 | message, |
37 | approver, |
38 | default_args, |
39 | dynamic_enums, |
40 | ) |
41 |
|
42 | return_object = {} |
43 |
|
44 | if dynamic_enums: |
45 | return_object["enums"] = dynamic_enums |
46 | if default_args: |
47 | return_object["default_args"] = default_args |
48 |
|
49 | return return_object |