Skip to content

feat: surface the setStatus argument to listeners if required event details are available#2843

Merged
zimeg merged 2 commits into
mainfrom
set-status
Apr 6, 2026
Merged

feat: surface the setStatus argument to listeners if required event details are available#2843
zimeg merged 2 commits into
mainfrom
set-status

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

These changes aim to widen the availability of setStatus to mirror the patterns established by sayStream

setStatus is available on app.event and app.message listeners, if Bolt fails to extract channel or thread_ts then setStatus will be undefined

Testing

  1. clone this branch
  2. build the project with npm pack .
  3. Import the package in a Bolt project
  4. Play around with setStatus
Sample app.ts
import { App, LogLevel } from '@slack/bolt';
import 'dotenv/config';

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

const app = new App({
token: process.env.SLACK_BOT_TOKEN,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
logLevel: LogLevel.DEBUG,
});

app.event('app_mention', async ({ sayStream, setStatus }) => {
setStatus({
  status: 'Thinking...',
  loading_messages: [
    'Waking up from my mass-production nap...',
    'Putting on my thinking cap...',
    'Consulting the ancient Stack Overflow...',
    'Bribing the servers with virtual cookies...',
    'Loading witty response... please hold...',
  ],
});
const stream = sayStream({ buffer_size: 100 });

await stream.append({ markdown_text: '*Someone rang the bat signal!* :bat:\n\n' });
await sleep(5000);
await stream.append({ markdown_text: "Oh wait, it's just an @mention. Even better!\n\n" });
await stream.append({
  markdown_text:
    "> Fun fact: I was mass-produced in a mass-production factory, but I like to think I'm *one of a kind*.\n\n",
});
await sleep(1000);
await stream.append({ markdown_text: "Anyway, here's my *totally professional* take:\n\n" });
await stream.append({
  markdown_text: "1. `sayStream` is basically magic — words appear like I'm *actually typing* :sparkles:\n",
});
await sleep(1000);
await stream.append({
  markdown_text: "2. Streaming means you don't have to stare at a blank screen wondering if I ghosted you\n",
});
await sleep(1000);
await stream.append({
  markdown_text: '3. Bolt for JavaScript makes building Slack apps easier than microwaving leftovers\n\n',
});
await sleep(500);
await stream.append({ markdown_text: '_*mic drop*_ :microphone:' });
await stream.stop();
});

app.message('', async ({ sayStream, setStatus }) => {
setStatus({
  status: 'Thinking...',
  loading_messages: [
    'Waking up from my mass-production nap...',
    'Putting on my thinking cap...',
    'Consulting the ancient Stack Overflow...',
    'Bribing the servers with virtual cookies...',
    'Loading witty response... please hold...',
  ],
});
const stream = sayStream({ buffer_size: 100 });

await stream.append({ markdown_text: '*Psst...* you just DMed a bot. Bold move. I respect that. :sunglasses:\n\n' });
await sleep(5000);
await stream.append({ markdown_text: 'Let me consult my *vast knowledge database*...\n\n' });
await stream.append({
  markdown_text: '```\n[ scanning... ]\n[ found: 1 brain cell ]\n[ deploying it now ]\n```\n\n',
});
await sleep(1000);
await stream.append({ markdown_text: "Okay here's the deal:\n\n" });
await sleep(1000);
await stream.append({
  markdown_text: ':rocket: *Streaming responses* means you get to watch me think in real time — terrifying, I know\n',
});
await sleep(1000);
await stream.append({
  markdown_text: ':hammer_and_wrench: *Bolt for JavaScript* is the secret sauce behind my dazzling personality\n',
});
await sleep(1000);
await stream.append({
  markdown_text: ':zap: *Socket Mode* keeps our conversation nice and private — no nosy webhooks here\n\n',
});
await sleep(500);
await stream.append({ markdown_text: "That's all I've got. Don't forget to tip your bot! :robot_face:" });
await stream.stop();
});

(async () => {
try {
  await app.start(process.env.PORT || 3000);
  app.logger.info('Bolt app is running!');
} catch (error) {
  app.logger.error('Unable to start App', error);
}
})();
manifest.json
{
    "_metadata": {
        "major_version": 1,
        "minor_version": 1
    },
    "display_information": {
        "name": "set_status_experiment"
    },
    "features": {
        "app_home": {
            "home_tab_enabled": false,
            "messages_tab_enabled": true,
            "messages_tab_read_only_enabled": false
        },
        "bot_user": {
            "display_name": "set_status_experiment",
            "always_online": false
        }
    },
    "oauth_config": {
        "scopes": {
            "bot": [
                "app_mentions:read",
                "chat:write",
                "im:read",
                "im:write",
                "channels:history",
                "im:history"
            ]
        }
    },
    "settings": {
        "event_subscriptions": {
            "bot_events": [
                "app_mention",
                "message.im"
            ]
        },
        "interactivity": {
            "is_enabled": true
        },
        "org_deploy_enabled": true,
        "socket_mode_enabled": true,
        "token_rotation_enabled": false
    }
}

Requirements

@WilliamBergamin WilliamBergamin added this to the 4.7.0 milestone Mar 30, 2026
@WilliamBergamin WilliamBergamin self-assigned this Mar 30, 2026
@WilliamBergamin WilliamBergamin requested a review from a team as a code owner March 30, 2026 21:43
@WilliamBergamin WilliamBergamin added enhancement M-T: A feature request for new functionality semver:minor labels Mar 30, 2026
@codecov

codecov Bot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.59%. Comparing base (175e0b1) to head (f507764).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2843      +/-   ##
==========================================
+ Coverage   93.58%   93.59%   +0.01%     
==========================================
  Files          43       44       +1     
  Lines        7836     7853      +17     
  Branches      685      686       +1     
==========================================
+ Hits         7333     7350      +17     
  Misses        498      498              
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@WilliamBergamin No notes but praise. This builds so well on your earlier efforts 🏆 ✨

Comment thread src/Assistant.ts
Comment on lines +349 to +352
function createAssistantSetStatus(args: AllAssistantMiddlewareArgs): SetStatusFn {
const { client, payload } = args;
const { channelId: channel_id, threadTs: thread_ts } = extractThreadInfo(payload);

return (status: Parameters<SetStatusFn>[0]): Promise<AssistantThreadsSetStatusResponse> => {
if (typeof status === 'string') {
return client.assistant.threads.setStatus({
channel_id,
thread_ts,
status,
});
}
return client.assistant.threads.setStatus({
channel_id,
thread_ts,
...status,
});
};
const { channelId, threadTs } = extractThreadInfo(payload);
return createSetStatus(client, channelId, threadTs);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎨 praise: Beautiful implementation for extending this to other listeners!

@srtaalej

srtaalej commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

thanks for the thorough sample files! made testing a breeze 😀

@srtaalej srtaalej 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.

Working great for me ⭐ ⭐ 🚀

@zimeg

zimeg commented Apr 6, 2026

Copy link
Copy Markdown
Member

@WilliamBergamin Thanks again for putting this together - let's merge it now! 🎁

@zimeg zimeg merged commit e81864a into main Apr 6, 2026
26 checks passed
@zimeg zimeg deleted the set-status branch April 6, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants