Bolt: @slack/[email protected] Release

Release date:
September 27, 2024
Previous version:
@slack/[email protected] (released September 11, 2024)
Magnitude:
23 Diff Delta
Contributors:
5 total committers
Data confidence:
Commits:

Top Contributors in @slack/[email protected]

lukegalbraithrussell
dependabot-bot
zimeg
helzahalim
ChinoUkaegbu

Directory Browser for @slack/[email protected]

All files are compared to previous version, @slack/[email protected]. Click here to browse diffs between other versions.

Loading File Browser...

Release Notes Published

What's new

This release adds support for the assistant.threads.* API methods introduced in @slack/[email protected] πŸ€– as well as improvements to documentation at the new https://tools.slack.dev/bolt-js site and patches to dependencies πŸ”’

Example usage

More details about these endpoints can be discovered in the documentation, and listeners can be added to code to respond to incoming events like so:


app.event('assistant_thread_started', async ({ client, event, logger }) => {
  logger.info('A new thread started');
  logger.debug(event);
  const now = new Date();
  const title = await client.assistant.threads.setTitle({
    title: `Chats from ${now.toISOString()}`,
    channel_id: event.assistant_thread.channel_id,
    thread_ts: event.assistant_thread.thread_ts,
  });
  logger.debug(title);
  const suggestions = await client.assistant.threads.setSuggestedPrompts({
    channel_id: event.assistant_thread.channel_id,
    thread_ts: event.assistant_thread.thread_ts,
    title: 'Ask the computer for answers',
    prompts: [
      {
        title: 'Find the time',
        message: `What happens at ${Math.floor(now.getTime() / 1000)}`,
      },
    ],
  });
  logger.debug(suggestions);
});

app.event('assistant_thread_context_changed', async ({ client, event, logger }) => {
  logger.info('The channel of focus changed');
  logger.debug(event);
  const response = client.chat.postMessage({
    thread_ts: event.assistant_thread.thread_ts,
    channel: event.assistant_thread.channel_id,
    text: `Now visiting <#${event.assistant_thread.context.channel_id}>`,
  });
  logger.debug(response);
});

app.message(async ({ client, message, logger }) => {
  logger.info('A new message was received');
  logger.debug(message);
  if (message.subtype === 'message_changed' || message.subtype === 'message_deleted') {
    return;
  }
  const status = await client.assistant.threads.setStatus({
    channel_id: message.channel,
    thread_ts: message.thread_ts,
    status: 'is thinking...',
  });
  logger.debug(status);
  /**
    * Actual response generation could happen here!
    */
  setTimeout(async () => {
    const response = await client.chat.postMessage({
      channel: message.channel,
      thread_ts: message.thread_ts,
      text: 'How insightful!',
    });
    logger.debug(response);
  }, 3000);
});

Changes

πŸ“š Documentation

πŸ“¦ Dependencies

πŸŽ‰ New contributors

Full Changelog: https://github.com/slackapi/bolt-js/compare/@slack/[email protected]...@slack/[email protected]