feat: add workflow form submission via --field#74
Open
shhac wants to merge 1 commit intostablyai:mainfrom
Open
feat: add workflow form submission via --field#74shhac wants to merge 1 commit intostablyai:mainfrom
shhac wants to merge 1 commit intostablyai:mainfrom
Conversation
Contributor
|
Thx for the PR as always! Will be able to look it over tmr :-D |
4dd76f8 to
508ce98
Compare
Add `--field Title=value` support to `workflow run`, enabling form submission through a short-lived RTM WebSocket that captures view_opened events and submits via views.submit. New modules: - rtm-websocket: low-level Bun-compatible WebSocket over node:https - workflow-submit: orchestrates trip → capture → submit flow
508ce98 to
ddccbad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--fieldsupport toworkflow run, enabling form submission for workflows that present an interactive form after being triggered. This was called out as a follow-up in #40:workflow run <trigger-id> --channel #ops --field "Title=My request" --field "Priority=High"--field, behavior is unchanged (trip-only, as before)xoxc/xoxd-- also from desktop app) — standard bot tokens can trip triggers but cannot interact with the modal formWhy WebSockets (RTM)
Slack's workflow forms use a
view_openedevent delivered over the RTM WebSocket to provide the modal'sview_idand block structure. There is no REST endpoint that returns this — the view is pushed to the client asynchronously after the trigger is tripped. Without a WebSocket listener, there's no way to know theview_idor theblock_id/action_idmappings needed to callviews.submit.I investigated alternatives (polling
views.*endpoints, intercepting via response_urls) but Slack doesn't expose the view through any other channel. WebSocket is the only path.Implementation
The WebSocket connection uses
node:httpsrequest upgrade (Upgrade: websocketheader) rather than theWebSocketglobal or a library. This approach works in Bun despite Bun's incomplete WebSocket client support for cookie-authenticatedwss://connections — the Node.jshttp.requestupgrade path is fully supported. The trade-off is manually parsing WebSocket frames (RFC 6455), but server→client frames are unmasked so the parser is straightforward.Flow
rtm.connect→ get WebSocket URLview_openedrunWorkflow)view_opened→ extractview_id+ block/action structure--fieldvalues to the correctblock_id/action_idpairs using the workflow schemaviews.submitwith the assembled stateNew files
src/lib/rtm-websocket.ts— short-lived RTM WebSocket connection with frame parsersrc/slack/workflow-submit.ts— form validation, submission orchestrationtest/rtm-websocket.test.ts— WebSocket frame parser unit teststest/workflow-submit.test.ts— field validation + auth guard testsNote
To my knowledge, no other Slack CLI tool supports workflow form submission — existing tools can only trip triggers. This fills a gap for automating workflows that require field input.
Test plan