github slackapi/bolt-js @slack/bolt@3.22.0

6 hours ago

What's new

This release adds support for the assistant.threads.* API methods introduced in @slack/web-api@6.13.0 🤖 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 === 'assistant_app_thread' || 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

  • chore(deps-dev): bump @types/node from 22.5.4 to 22.5.5 - Thanks @dependabot! #2263
  • Upgrade express version - Thanks @helzahalim! #2270
  • chore(deps): bump @slack/web-api from 6.12.1 to 6.13.0 - Thanks @zimeg! #2273

🎉 New contributors

Full Changelog: https://github.com/slackapi/bolt-js/compare/@slack/bolt@3.21.4...@slack/bolt@3.22.0

Don't miss a new bolt-js release

NewReleases is sending notifications on new releases.