Skip to content

feat(slack): assistant thread ops, paginated history/replies, and permalink#4934

Merged
waleedlatif1 merged 5 commits into
stagingfrom
feat/slac
Jun 10, 2026
Merged

feat(slack): assistant thread ops, paginated history/replies, and permalink#4934
waleedlatif1 merged 5 commits into
stagingfrom
feat/slac

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Add three assistant-thread tools — slack_set_status, slack_set_title, slack_set_suggested_prompts (assistant.threads.*) — covering the full Slack AI app thread API
  • Add slack_get_channel_history and slack_get_thread_replies — paginated conversations.history / conversations.replies that follow next_cursor internally (with Retry-After handling) instead of one page at a time
  • Add slack_get_permalink (chat.getPermalink)
  • Wire all six as Slack block operations (subBlocks, conditions, params, outputs)
  • Add OAuth scopes assistant:write, im:history, mpim:read, mpim:history (+ consent-modal labels) and manifest capabilities action_read_history / action_assistant
  • Fix invite_to_conversation to handle Slack's documented no_user error code; widen DM history scope hints on get_message / get_thread
  • Regenerate tool docs and integrations catalog

Type of Change

  • New feature

Testing

Full /validate-integration audit of all ~35 Slack tools against the live Slack Web API docs — no critical endpoint/method/field/response misalignments. tsc --noEmit clean, bun run lint clean, bun run check:api-validation passes.

Note: list_canvases filters files.list with types=canvas, which isn't a documented types value (Slack lists spaces for canvases). This is pre-existing and unverified against a live workspace, so it's left unchanged — worth a follow-up check.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

… permalink

- New tools: slack_set_status, slack_set_title, slack_set_suggested_prompts
  (assistant.threads.*), slack_get_channel_history + slack_get_thread_replies
  (paginated conversations.history/replies via directExecution), slack_get_permalink
- Wire all six as Slack block operations with subBlocks, conditions, params, outputs
- Add scopes: assistant:write, im:history, mpim:read, mpim:history (+ consent labels)
- Add manifest capabilities: action_read_history, action_assistant
- Fix invite_to_conversation no_user error code; widen DM history scope hints
- Regenerate tool docs and integrations catalog
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 10, 2026 1:16am

Request Review

@cursor

cursor Bot commented Jun 10, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Expands OAuth scopes and adds paginated history reads that can pull large message volumes; existing workspaces must reconnect for assistant:write and new history capabilities.

Overview
Adds six Slack tools and wires them through the Slack workflow block, tool registry, types, and regenerated docs/catalog.

Read APIs: slack_get_channel_history and slack_get_thread_replies use a shared fetchSlackMessagesPaginated helper to walk next_cursor (with Retry-After retries), optional time filters, and maxPages caps. slack_get_permalink wraps chat.getPermalink.

Slack AI assistant threads: slack_set_status, slack_set_title, and slack_set_suggested_prompts call assistant.threads.* and require the new assistant:write OAuth scope (plus consent labels and trigger capabilities action_read_history / action_assistant).

Smaller fixes: invite_to_conversation treats Slack’s no_user error; get_message / get_thread missing-scope hints mention DM/MPIM history scopes.

The Slack block gains matching operations, UI fields (pagination, status, prompts, etc.), and param mapping for all six tools.

Reviewed by Cursor Bugbot for commit 966ec8a. Configure here.

Comment thread apps/sim/tools/slack/get_thread_replies.ts Outdated
Comment thread apps/sim/tools/slack/get_channel_history.ts Outdated
Comment thread apps/sim/tools/slack/set_suggested_prompts.ts
@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds six new Slack tools — three assistant.threads.* operations (set_status, set_title, set_suggested_prompts), two paginated history tools (get_channel_history, get_thread_replies), and get_permalink — together with their block wiring, OAuth scope additions, and two new Bot Manifest capabilities.

  • New tools (set_status, set_title, set_suggested_prompts) cover the full Slack AI-app assistant thread API, with input normalization for loading_messages and prompts, and proper error handling for assistant:write-scoped errors.
  • Paginated history tools (get_channel_history, get_thread_replies) implement Retry-After back-off and follow next_cursor internally up to a configurable maxPages, solving the "one page at a time" limitation of the older get_thread / get_message tools.
  • get_permalink wraps chat.getPermalink and reuses the existing messageTs block field, avoiding duplicate UI inputs; scope-hint strings in get_message / get_thread / get_channel_history / get_thread_replies were widened to include the newly granted DM and MPIM history scopes.

Confidence Score: 4/5

Safe to merge for all new assistant-thread and permalink operations, but DM/MPIM channel history reads will remain broken for OAuth users until the three missing scopes are added to the grant.

The new tool implementations are well-structured — pagination, retry logic, input normalization, and error messages are all correct. The OAuth grant received assistant:write but still omits im:history, mpim:read, and mpim:history, which were explicitly called out in the PR description. Users who connect via OAuth and call get_channel_history or get_thread_replies against a DM or group-DM channel will hit missing_scope, be told to reconnect with those scopes, and then find that reconnecting still does not grant them — leaving them stuck.

apps/sim/lib/oauth/oauth.ts — the three history scopes for DM and MPIM channels need to be added to the Slack OAuth grant before DM/MPIM paginated reads work end-to-end.

Important Files Changed

Filename Overview
apps/sim/lib/oauth/oauth.ts Adds assistant:write to the Slack OAuth grant, but im:history, mpim:read, and mpim:history — listed in the PR description and referenced in tool scope hints — are still absent, meaning DM/MPIM history reconnects won't resolve missing_scope errors.
apps/sim/tools/slack/utils.ts Adds fetchSlackMessagesPaginated with Retry-After back-off and mapSlackMessage normalizer. Logic is sound; minor: abandoned 429 response bodies in the retry loop are never drained, which may delay connection-pool return.
apps/sim/blocks/blocks/slack.ts Wires all six new operations into the block: subBlocks, conditions, params mapping, and outputs. Reuses existing messageTs/threadTs block fields to avoid duplication. All existing outputs were already declared; only pages, threadTs, and permalink are newly added.
apps/sim/tools/slack/get_channel_history.ts New paginated channel-history tool; delegates fully to fetchSlackMessagesPaginated. Scope hint now includes im:history and mpim:history. Clean.
apps/sim/tools/slack/get_thread_replies.ts New paginated thread-replies tool; correctly separates parent message from replies using ts equality. Scope hint includes all four history scopes.
apps/sim/tools/slack/set_status.ts New assistant thread status tool; normalizeLoadingMessages safely handles string/array/JSON inputs. Sends empty string to clear status as documented.
apps/sim/tools/slack/set_title.ts New assistant thread title tool. Straightforward POST with correct error handling for assistant:write-scoped errors.
apps/sim/tools/slack/set_suggested_prompts.ts New suggested-prompts tool; normalizePrompts handles JSON-string or structured-array input. Throws from body() when prompts list is empty — executor wraps this in try-catch so it results in a user-facing error.
apps/sim/tools/slack/get_permalink.ts Clean chat.getPermalink wrapper using transformResponse. Error cases for invalid_auth, channel_not_found, and message_not_found are all handled.
apps/sim/triggers/slack/capabilities.ts Adds action_read_history and action_assistant bot manifest capabilities. Clean.

Reviews (5): Last reviewed commit: "fix(slack): narrow set_status missing_sc..." | Re-trigger Greptile

Comment thread apps/sim/tools/slack/get_channel_history.ts
Comment thread apps/sim/tools/slack/get_channel_history.ts Outdated
Comment thread apps/sim/tools/slack/get_thread_replies.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

… hints, reject empty suggested prompts

- get_thread_replies: identify thread parent by ts === thread_ts instead of
  assuming index 0, so cursor-resumed pages (which omit the parent) no longer
  mislabel a reply as the parent
- get_channel_history + get_thread_replies: include im:history/mpim:history in
  the missing_scope hint to match the OAuth grant and DM/MPIM reads
- set_suggested_prompts: throw a clear error when no valid prompt is provided
  instead of silently calling Slack with an empty prompts array
Comment thread apps/sim/tools/slack/get_channel_history.ts Outdated
…history scopes

- Add resolvePositiveInt helper and use it for limit/maxPages in
  get_channel_history and get_thread_replies, so a non-numeric value (e.g. from
  an LLM) no longer becomes NaN and silently disables pagination (returning an
  empty success)
- Remove im:history/mpim:read/mpim:history from the Slack OAuth grant — the Slack
  app does not have these scopes; assistant:write is the only added scope
- Drop the explanatory inline comment in get_thread_replies
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/oauth/oauth.ts
…ed mode

Matches the existing paginationCursor convention in the block — keeps the basic
UI focused on channel + time filters while pagination internals live under
advanced.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5d1fa8b. Configure here.

A user hitting missing_scope on set_status already has chat:write (long
granted); the scope they actually need is assistant:write, which is also what
set_title/set_suggested_prompts point to. Narrow the hint to assistant:write for
accurate, consistent guidance.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile addressed in 966ec8a — narrowed the set_status missing_scope hint to assistant:write. Note for the record: per the live Slack docs, assistant.threads.setStatus currently accepts either chat:write or assistant:write (and is slated to move to chat:write-only), so the original hint wasn't strictly wrong — but assistant:write is the scope a user is actually missing here (chat:write is long-granted) and it's consistent with the set_title/set_suggested_prompts hints, so narrowing it is clearer guidance.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Makes sense — actionable error hints should point to what the user is actually missing, not enumerate all scopes that technically satisfy the requirement. Since chat:write is baseline-granted, assistant:write is the right signal here, and the consistency with set_title/set_suggested_prompts is a bonus. Good call narrowing it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 966ec8a. Configure here.

@waleedlatif1 waleedlatif1 merged commit 209501e into staging Jun 10, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/slac branch June 10, 2026 01:28
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.

1 participant