Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion services/hackbot-api/app/routers/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ async def slack_interactions(request: Request) -> Response:
match action.value.type:
case "start_agent_run":
client = get_hackbot_client()
client.trigger_run(action.value.agent_name, action.value.inputs)
await client.trigger_run(
action.value.agent_name,
action.value.params,
)
case _:
raise ValueError("Unsupported action type: %s" % action.value.type)

Expand Down
44 changes: 44 additions & 0 deletions services/hackbot-api/tests/test_slack_webhook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import json

from app.auth import require_slack_signature
from app.main import app
from app.routers import slack


class _FakeHackbotClient:
def __init__(self):
self.calls = []

async def trigger_run(self, agent_name, inputs):
self.calls.append((agent_name, inputs))


def test_start_agent_run_action_triggers_run(client, monkeypatch):
api_client = _FakeHackbotClient()
app.dependency_overrides[require_slack_signature] = lambda: None
monkeypatch.setattr(slack, "get_hackbot_client", lambda: api_client)
payload = {
"type": "block_actions",
"user": {"id": "U123", "username": "user"},
"actions": [
{
"action_id": "start",
"value": json.dumps(
{
"type": "start_agent_run",
"agent_name": "bug-fix",
"params": {"bug_id": 123},
}
),
}
],
"trigger_id": "trigger-123",
}

response = client.post(
"/webhooks/slack/interactions",
data={"payload": json.dumps(payload)},
)

assert response.status_code == 200
assert api_client.calls == [("bug-fix", {"bug_id": 123})]