Skip to content

fix(slack): handle approval buttons inline and update message after response#11665

Merged
AhmadTash merged 4 commits intomainfrom
fix/slack-approval-buttons
Mar 17, 2026
Merged

fix(slack): handle approval buttons inline and update message after response#11665
AhmadTash merged 4 commits intomainfrom
fix/slack-approval-buttons

Conversation

@AhmadTash
Copy link
Collaborator

What does this PR do?

Fixes Slack approval flow buttons opening a JSON link in the browser and not getting disabled after clicking.

Explain How the Feature Works

Previously, the "Request Approval in a Channel" and "Request Approval from a User" actions used Slack button url properties, which opened the resume webhook URL directly in the browser — showing raw JSON to the user. Buttons also remained clickable after responding, causing confusion.

This PR makes two changes:

  1. Buttons now use value instead of url — Button clicks are handled inline via Slack's interactivity webhook and forwarded server-side by the existing parseAndReply handler. No browser tab opens.

  2. Message updates after response — On flow resume, the Slack message is updated via chat.update to replace the interactive buttons with a status indicator (:white_check_mark: Approved or :x: Disapproved), giving clear visual feedback.

Also adds the missing channel query param to the DM approval action so the message can be updated on resume.

Relevant User Scenarios

  • Users running approval workflows via Slack were confused by a browser tab opening with raw JSON when clicking Approve/Disapprove.
  • After clicking a button, there was no visual feedback — buttons stayed active, leading to repeated clicks and uncertainty about approval status.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 10, 2026

Confidence Score: 3/5

  • Needs fixes before merging — the BEGIN branch chat.update is unguarded and can leave users with an un-actionable approval message.
  • The core fix (value vs url, RESUME branch update, correct token usage) is implemented correctly. However, the unguarded chat.update in the BEGIN branch of both files is a real logic hazard: a Slack API error there terminates execution before the flow is paused, resulting in a dangling message with no buttons. This path is reachable in common setups (bot not yet invited to channel, missing chat:write scope) and would produce a confusing user experience.
  • request-approval-direct-message.ts lines 54–88 and request-approval-message.ts lines 60–94 — the unguarded chat.update in the BEGIN branch needs error handling.

Important Files Changed

Filename Overview
packages/pieces/community/slack/src/lib/actions/request-approval-direct-message.ts Switches DM approval buttons from url to value, adds missing channel query param, and adds a RESUME branch that calls chat.update with getBotToken. Previously flagged issues (wrong token, unhandled exception) have been resolved. The silent catch block around chat.update is intentional per the author's inline comment.
packages/pieces/community/slack/src/lib/actions/request-approval-message.ts Switches channel approval buttons from url to value, and adds RESUME branch logic to update the message via chat.update using getBotToken. The channel query param was already present for the channel action. Mirrors the structure of the DM action; the same intentional silent catch pattern is in place.
packages/pieces/community/slack/package.json Patch version bump from 0.14.0 to 0.14.1, consistent with the scope of this bug-fix change.

Comments Outside Diff (1)

  1. packages/pieces/community/slack/src/lib/actions/request-approval-direct-message.ts, line 54-88 (link)

    Unhandled chat.update failure in BEGIN branch

    The client.chat.update() call that adds buttons to the initial message (lines 54–88) has no error handling. If it fails (e.g., missing chat:write scope, rate limit, or race condition), the exception will propagate and the entire BEGIN execution will fail — the flow never reaches context.run.pause() and no webhook URL is ever registered. The user will see the plain-text message with no buttons and no way to approve or disapprove.

    This is especially worth guarding against because the message has already been sent to the user by slackSendMessage at this point, so a failure here leaves a "zombie" message with no interactive controls.

    Consider wrapping this call in a try/catch (or making it fail-safe) and either rethrowing a user-friendly error or falling back to sending a new message with buttons already included so the flow can still be paused correctly:

    try {
      await client.chat.update({
        ts: messageTs,
        channel: dmId,
        text: context.propsValue.text,
        blocks: [ /* ... */ ],
      });
    } catch (e) {
      throw new Error(
        'Failed to attach approval buttons to the Slack message. Please check the bot has the chat:write scope.'
      );
    }

Last reviewed commit: 371c288

@AhmadTash AhmadTash requested a review from kishanprmr March 10, 2026 22:41
@askgauravarya
Copy link

Hi @kishanprmr @AhmadTash can you please resolve this and merge? 🙏

… error

The resume branch was accessing context.auth.access_token directly,
which doesn't exist on the union type. Use getBotToken helper instead.
@AhmadTash AhmadTash merged commit 8dc7611 into main Mar 17, 2026
15 checks passed
pdfcrowd pushed a commit to pdfcrowd/activepieces that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants