Skip to content

Add follow-up forms to Slack and Teams Request Action buttons - #2702

Merged
ravikiranvm merged 3 commits into
mainfrom
ops-5060
Nov 27, 2026
Merged

ravikiranvm merged 3 commits into
mainfrom
ops-5060

Conversation

@ravikiranvm

@ravikiranvm ravikiranvm commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Part of OPS-5060.

What changes for users

  • A button in the Slack or Microsoft Teams Request Action step can open a form with several questions. Until now a button could ask one question only.
  • The form is described in one new button setting, Follow-up form, as JSON: an optional heading and subtitle, a list of fields, and an optional skip button.
  • Field types: text, email, number, dropdown and multi-line text. Fields are required unless marked optional, and each can have a hint.
  • Each answer comes back in the step output as parameters.<field name>.
  • The three old button settings (Follow-up question, Answer format, No answer option) are removed from the builder. The new setting covers everything they did.
  • The form page shows a specific error under each field ("This field is required.", "Enter a valid email address."), marks the field in red, and clears the error as soon as it is corrected.
  • If a form makes a Slack button link longer than Slack allows (3,000 characters), the step now fails with a message that says so. Before, Slack rejected the whole message and the recipient got nothing.

Example:

{
  "title": "Why are you dismissing this?",
  "fields": [
    { "name": "reason", "label": "Reason", "type": "select", "options": ["Still in use", "Scheduled for decommissioning", "Other"] },
    { "name": "comment", "label": "Comment", "type": "textarea", "required": false, "hint": "Add any details that help us follow up" }
  ]
}
Button setting Form the recipient sees

Existing flows keep working

  • A flow that still sends the old three values, for example from a code step that builds the buttons, gets the same one-question form as before, answered as parameters.answer.
  • Messages sent before this change still open: the page keeps reading the old link format.
  • A flow where the old values were typed into the builder keeps working too, but those values are no longer shown in the builder. No migration is included; we don't expect such flows to exist.

Deployment note

Deploy the app together with or before the worker. New messages use a link format that the previous form page cannot read, so with a new worker and an old app, form buttons show "This link is invalid" until the app is updated.

Alternatives considered

  • More single-purpose settings (a dropdown format, a list of values, a second question): fewer changes now, but every new kind of form would need new settings in both blocks. One JSON setting covers any form.
  • Saving the form on the server and serving it from a new public endpoint, so the link stays short: built and removed. It adds an unauthenticated endpoint and a stored row per button that nothing cleans up. The form in the link needs neither; the Slack limit leaves room for roughly 70 dropdown values.
  • Native forms inside Slack or Teams: Teams cards sent through Microsoft Graph cannot submit input without a bot, and a Slack modal would work in Slack only. A browser page is the one approach that works in both.

Testing

  • Automated: new tests for the form format, the link builder, the form page (loaded in a simulated browser with links built by the same code the blocks use), and both blocks, including buttons that still send the old values.
  • Manual, local, Slack and Teams: a form with a dropdown and a text area; a 2,900-character message with a link close to the Slack limit; a form built by a code step and passed by reference.
  • Manual, local, Slack: notifications from a flow that sends the old three values, launched before and after this change, including the skip option and ordinary buttons.
  • Manual: the form page in Chrome, including error states, a narrow window and an old-format link.
  • Not run: Slack with interactions enabled (needs an environment Slack can reach), and the old three values through a Teams message outside the automated tests.

Docs: openops-cloud/docs#357 (draft until this is released).

A button in the Slack or Microsoft Teams Request Action step can now
open a form with several fields, described by one JSON setting,
followUpForm. Each answer returns to the flow as parameters.<field name>.

The setting replaces the three single-question settings (follow-up
question, answer format, no answer option). Flows that still send those
values keep working: they are converted to a one-field form answered as
parameters.answer, and links from messages already sent still open.

The form travels in the button link. The Slack step fails with a clear
error when a link would exceed Slack's 3,000-character limit, instead
of Slack rejecting the whole message.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@linear

linear Bot commented Nov 27, 2026

Copy link
Copy Markdown

OPS-5060

Call parseField through an explicit callback, and use the constructs
SonarCloud prefers in the form page (sets, replaceAll, codePointAt,
before).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@ravikiranvm
ravikiranvm requested a balanced review from Copilot November 27, 2026 10:40
@ravikiranvm
ravikiranvm marked this pull request as ready for review November 27, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valid dropdown selections can be rejected by the free-text length limit, and large encoded answers can trigger HTTP 414 while falsely reporting success and leaving the workflow paused.

2 open issues
What changed in this PR

Adds multi-field follow-up forms to Slack and Microsoft Teams Request Action buttons, using a shared form definition and the existing browser-based workflow resume flow.

Changes:

  • Replaces three button settings with one JSON form setting while preserving legacy questions and links.
  • Adds five field types, optional fields, hints, skip controls, and field-level validation.
  • Adds Slack button-link length checks and tests for parsing, links, rendering, and both integrations.

Blocking: Two required fixes remain.
Non-blocking: None.
Merge recommendation: Do not merge

File Description
packages/​react-ui/​public/​html/​collect_input.html Renders and validates multi-field forms while supporting legacy links.
packages/​openops/​test/​follow-up-form.test.ts Tests form parsing and legacy button conversion.
packages/​openops/​test/​collect-input-page.test.ts Tests rendering, validation, submission, and compatibility.
packages/​openops/​test/​build-wrapper-url.test.ts Tests encoded form links and title truncation.
packages/​openops/​src/​lib/​follow-up-form.ts Defines shared form types, validation, encoding, and button settings.
packages/​openops/​src/​lib/​build-wrapper-url.ts Builds form links with encoded definitions.
packages/​openops/​src/​index.ts Exports shared form utilities.
packages/​blocks/​slack/​test/​request-action-message.test.ts Tests form buttons, compatibility, and oversized-link rejection.
packages/​blocks/​slack/​src/​lib/​common/​props.ts Exposes the new JSON form setting.
packages/​blocks/​slack/​src/​lib/​actions/​request-action-message.ts Resolves forms and enforces Slack’s button-link limit.
packages/​blocks/​microsoft-teams/​test/​request-action-message.test.ts Tests plain, legacy, and form buttons.
packages/​blocks/​microsoft-teams/​src/​lib/​common/​generate-message-with-buttons.ts Uses shared button form types.
packages/​blocks/​microsoft-teams/​src/​lib/​actions/​request-action-message.ts Exposes form settings and generates form links.

Review effort: Balanced

Comment on lines +516 to +518
Object.entries(answers).forEach(([name, value]) => {
target.searchParams.set(name, value);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, and the numbers match what I measured: one text area with 1,000 CJK characters makes a request of about 9,200 characters, two make about 18,200, against the 16,384 limit in our nginx templates. With Latin text, 1,000 characters is about 1,200.

Leaving this as is for now. The risk is low and accepted: it needs two text areas filled to the limit with non-Latin text, and no form we plan has more than one text area. It is also one case of a broader, existing limitation, that the page does not check the server's reply before saying the response was recorded. That is better solved as a whole than with a size guard here.

}

// The message-button setting in the Slack and Teams "Request Action" steps.
export const followUpFormProperty = Property.Json({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RISK] If the JSON in followUpForm doesn't parse, the form is dropped without any error.

  • The builder's JSON editor saves invalid JSON as the raw string (tryParseJson), and the form schema accepts any string.
  • At run time the engine's jsonProcessor logs a warning and returns undefined. The property isn't required, so validation passes.
  • resolveButtonForm then treats the setting as empty, and the button resumes the flow without asking anything.

So a typo such as a trailing comma silently disables the form, which contradicts "an invalid form fails the step".

Fix: use a LongText property (or accept a string here) and call JSON.parse inside resolveButtonForm/parseFollowUpForm. On failure, throw Invalid follow-up form: not valid JSON. Add a test for a malformed string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid as described: unparseable JSON is saved as text by the builder and dropped by the engine, so the button is sent without a form.

Leaving this as is. The risk is low and accepted:

  • The builder's JSON editor underlines a syntax error in red when it is typed (checked on staging).
  • A full run of the workflow shows the problem at once, because the button resumes the flow without opening a form.
  • Forms produced by a code step are objects, not text, so they are not affected.

Switching the setting to plain text would lose the JSON editor and make references inside the form fragile. The cleaner fix is for the engine to fail a step on unparseable JSON in any JSON setting, which is a product-wide change and out of scope here.

@openops-hq-agent

openops-hq-agent Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude PR Review — #2702: Add follow-up forms to Slack and Teams Request Action buttons

Author: ravikiranvm | Base: main | Labels: none

Verdict

SHIP WITH CARE — the code is correct and well tested. Follow the deploy order in the description: release the app before or together with the worker.

Summary

This PR replaces the three single-question button settings with one followUpForm JSON setting. The setting is validated in packages/openops/src/lib/follow-up-form.ts and sent as base64url in the link to collect_input.html. The page builds a form with several fields and returns each answer as parameters.<field name>.

Older setups keep working:

  • Flows that still send followUpQuestion, answerFormat and noAnswerOption get a one-field form answered as parameters.answer.
  • Links in messages sent before this change still open, because the page still reads question=.

Overall risk is low. The change touches only the two Request Action blocks, the shared helper in @openops/common and a static HTML page. There are no API, database or engine changes.

What I checked and found sound:

  • Reserved names: RESERVED_FOLLOW_UP_FIELD_NAMES covers every routing param that the resume handlers filter out (EXCLUDED_RESUME_PARAMS in the Slack wait-for-interaction.ts and the Teams on-action-received.ts). It also covers button, which Teams routing uses, and the prototype-pollution keys. The page enforces the same list again.
  • Fail before sending: both blocks resolve and validate every form before they send anything. A bad form, or a Slack link over 3,000 characters, fails the step with a clear message instead of producing a broken or empty message.
  • Slack interactions: followUpActions now keys on action.form, so a button with a form still opens the page instead of resuming the flow directly through the interactions endpoint.
  • Button payloads: createButton (Slack) and the Teams card builder pick fields one by one. The new form and followUpForm objects never go into a Slack or Teams payload.
  • Page safety: the page writes all text with textContent, so there is no XSS. redirectUrl must still be same-origin and match the resume path.

Findings

No new findings at confidence ≥ 75.

Already covered by other reviewers

  • Dropdown options longer than 254 characters were blocked by the text length limit: fixed in ef7787b.
  • Large textarea answers can exceed the nginx 16 KiB request line limit (HTTP 414) while the page reports success: the author acknowledged this and accepted the risk.
  • JSON in followUpForm that doesn't parse is dropped without an error: the author acknowledged this and accepted the risk.

Testing gaps

None blocking. As the PR states, Slack with interactions enabled was not tested end to end, and neither were the old three values in a live Teams message.

A dropdown value comes from the configured list and cannot be shortened
by the recipient, so a long option was rejected on submit.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@ravikiranvm
ravikiranvm requested a review from pawel-oo November 27, 2026 11:12
@ravikiranvm
ravikiranvm merged commit b893976 into main Nov 27, 2026
22 checks passed
@ravikiranvm
ravikiranvm deleted the ops-5060 branch November 27, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants