Skip to content

Commit

Permalink
chore: update terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin committed Aug 22, 2024
1 parent e617f25 commit 5796349
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bolt for Python Custom Function Template
# Bolt for Python Custom Step Template

This is a Bolt for Python template app used to build custom functions for use in
This is a Bolt for Python template app used to build custom steps for use in
[Workflow Builder](https://api.slack.com/start#workflow-builder).

## Setup
Expand Down Expand Up @@ -82,7 +82,7 @@ ruff check --fix

## Using Steps in Workflow Builder

With your server running, your function is now ready for use in
With your server running, your step is now ready for use in
[Workflow Builder](https://api.slack.com/start#workflow-builder)! Add it as a
custom step in a new or existing workflow, then run the workflow while your app
is running.
Expand Down
16 changes: 8 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
logging.basicConfig(level=logging.DEBUG)


@app.function("sample_function")
def handle_sample_function_event(inputs: dict, say: Say, fail: Fail, logger: logging.Logger):
@app.function("sample_step")
def handle_sample_step_event(inputs: dict, say: Say, fail: Fail, logger: logging.Logger):
user_id = inputs["user_id"]

try:
say(
channel=user_id, # sending a DM to this user
text="Click the button to signal the function has completed",
text="Click the button to signal the step has ended",
blocks=[
{
"type": "section",
"text": {"type": "mrkdwn", "text": "Click the button to signal the function has completed"},
"text": {"type": "mrkdwn", "text": "Click the button to signal the step has ended"},
"accessory": {
"type": "button",
"text": {"type": "plain_text", "text": "Complete function"},
"text": {"type": "plain_text", "text": "Complete step"},
"action_id": "sample_click",
},
}
],
)
except Exception as e:
logger.exception(e)
fail(f"Failed to handle a function request (error: {e})")
fail(f"Failed to handle a step request (error: {e})")


@app.action("sample_click")
Expand All @@ -48,11 +48,11 @@ def handle_sample_click(
text="Congrats! You clicked the button",
)

# Signal that the function completed successfully
# Signal that the step completed successfully
complete({"user_id": context.actor_user_id})
except Exception as e:
logger.exception(e)
fail(f"Failed to handle a function request (error: {e})")
fail(f"Failed to handle a step request (error: {e})")


if __name__ == "__main__":
Expand Down
16 changes: 10 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
},
"settings": {
"event_subscriptions": {
"bot_events": ["function_executed"]
"bot_events": [
"function_executed"
]
},
"org_deploy_enabled": true,
"socket_mode_enabled": true,
Expand All @@ -20,13 +22,15 @@
},
"oauth_config": {
"scopes": {
"bot": ["chat:write"]
"bot": [
"chat:write"
]
}
},
"functions": {
"sample_function": {
"title": "Sample function",
"description": "Runs sample function",
"sample_step": {
"title": "Sample step",
"description": "Runs sample step",
"input_parameters": {
"user_id": {
"type": "slack#/types/user_id",
Expand All @@ -41,7 +45,7 @@
"user_id": {
"type": "slack#/types/user_id",
"title": "User",
"description": "User that completed the function",
"description": "User that completed the step",
"is_required": true,
"name": "user_id"
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from slack_bolt import BoltContext
from slack_sdk import WebClient

from app import handle_sample_click, handle_sample_function_event
from app import handle_sample_click, handle_sample_step_event

restore_os_env(old_env)

Expand All @@ -26,12 +26,12 @@ def setup_method(self):
def teardown_method(self):
restore_os_env(self.old_os_env)

def test_handle_sample_function_event(self):
def test_handle_sample_step_event(self):
fake_inputs = {"user_id": "U1234"}
fake_say = MagicMock()
fake_fail = MagicMock()

handle_sample_function_event(
handle_sample_step_event(
inputs=fake_inputs, say=fake_say, fail=fake_fail, logger=logging.Logger("tests/test_app.py")
)

Expand Down

0 comments on commit 5796349

Please sign in to comment.