How to integrate Slackbot MCP with OpenAI Agents SDK

This guide walks you through connecting Slackbot to the OpenAI Agents SDK using the Composio tool router. By the end, you'll have a working Slackbot agent that can send daily standup reminder to #engineering, add a custom emoji for our new logo, archive the #old-projects channel this week through natural language commands. This guide will help you understand how to give your OpenAI Agents SDK agent real control over a Slackbot account through Composio's Slackbot MCP server. Before we dive in, let's take a quick look at the key ideas and tools involved.

Slackbot logoSlackbot
Oauth2

Slackbot is a conversational automation tool for Slack that handles reminders, notifications, and automated responses. It boosts team productivity by streamlining onboarding, answering FAQs, and managing timely alerts—all right inside Slack.

85 Tools8 Triggers

Introduction

This guide walks you through connecting Slackbot to the OpenAI Agents SDK using the Composio tool router. By the end, you'll have a working Slackbot agent that can send daily standup reminder to #engineering, add a custom emoji for our new logo, archive the #old-projects channel this week through natural language commands.

This guide will help you understand how to give your OpenAI Agents SDK agent real control over a Slackbot account through Composio's Slackbot MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Slackbot with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Install the necessary dependencies
  • Initialize Composio and create a Tool Router session for Slackbot
  • Configure an AI agent that can use Slackbot as a tool
  • Run a live chat session where you can ask the agent to perform Slackbot operations

What is OpenAI Agents SDK?

The OpenAI Agents SDK is a lightweight framework for building AI agents that can use tools and maintain conversation state. It provides a simple interface for creating agents with hosted MCP tool support.

Key features include:

  • Hosted MCP Tools: Connect to external services through hosted MCP endpoints
  • SQLite Sessions: Persist conversation history across interactions
  • Simple API: Clean interface with Agent, Runner, and tool configuration
  • Streaming Support: Real-time response streaming for interactive applications

What is the Slackbot MCP server, and what's possible with it?

The Slackbot MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Slackbot account. It provides structured and secure access to your Slack workspace, so your agent can automate reminders, manage conversations, add emoji reactions, organize channels, and streamline team notifications on your behalf.

  • Automated reminders and notifications: Ask your agent to create timely Slack reminders for you or your team using natural language or custom schedules—never miss a deadline or meeting again.
  • Message reactions and engagement: Let your agent add emoji reactions to messages, star important items, or highlight key conversations to keep team morale up and draw attention where needed.
  • Channel and conversation management: Have your agent archive inactive channels, close direct messages, or organize your workspace by cleaning up conversations—all with just a simple command.
  • Custom emoji and file integration: Direct your agent to add new custom emoji, set emoji aliases, or reference external files (like Google Drive docs) for richer, more expressive communication.
  • Participant and workflow automation: Empower your agent to add call participants, automate onboarding flows, or handle repetitive Slack tasks to keep your team focused and productive.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step09 STEPS
1

Prerequisites

Before starting, make sure you have:
  • Composio API Key and OpenAI API Key
  • Primary know-how of OpenAI Agents SDK
  • A live Slackbot project
  • Some knowledge of Python or Typescript
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
3

Install dependencies

npm install @composio/openai-agents @openai/agents dotenv

Install the Composio SDK and the OpenAI Agents SDK.

4

Set up environment variables

bash
OPENAI_API_KEY=sk-...your-api-key
COMPOSIO_API_KEY=your-api-key
USER_ID=composio_user@gmail.com

Create a .env file and add your OpenAI and Composio API keys.

5

Import dependencies

import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';
What's happening:
  • You're importing all necessary libraries.
  • The Composio and OpenAIAgentsProvider classes are imported to connect your OpenAI agent to Composio tools like Slackbot.
6

Set up the Composio instance

dotenv.config();

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});
What's happening:
  • dotenv.config() loads your .env file so COMPOSIO_API_KEY and USER_ID are available as environment variables.
  • Creating a Composio instance using the API Key and OpenAIAgentsProvider class.
7

Create a Tool Router session

// Create Tool Router session for Slackbot
const session = await composio.create(userId as string, {
  toolkits: ['slackbot'],
});
const mcpUrl = session.mcp.url;

What is happening:

  • You give the Tool Router the user id and the toolkits you want available. Here, it is only slackbot.
  • The router checks the user's Slackbot connection and prepares the MCP endpoint.
  • The returned session.mcp.url is the MCP URL that your agent will use to access Slackbot.
  • This approach keeps things lightweight and lets the agent request Slackbot tools only when needed during the conversation.
8

Configure the agent

// Configure agent with MCP tool
const agent = new Agent({
  name: 'Assistant',
  model: 'gpt-5',
  instructions:
    'You are a helpful assistant that can access Slackbot. Help users perform Slackbot operations through natural language.',
  tools: [
    hostedMcpTool({
      serverLabel: 'tool_router',
      serverUrl: mcpUrl,
      headers: { 'x-api-key': composioApiKey },
      requireApproval: 'never',
    }),
  ],
});
What's happening:
  • We're creating an Agent instance with a name, model (gpt-5), and clear instructions about its purpose.
  • The agent's instructions tell it that it can access Slackbot and help with queries, inserts, updates, authentication, and fetching database information.
  • The tools array includes a hostedMcpTool that connects to the MCP server URL we created earlier.
  • The headers object includes the Composio API key for secure authentication with the MCP server.
  • requireApproval: 'never' means the agent can execute Slackbot operations without asking for permission each time, making interactions smoother.
9

Start chat loop and handle conversation

// Keep conversation state across turns
const conversationSession = new OpenAIConversationsSession();

// Simple CLI
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: 'You: ',
});

console.log('\nComposio Tool Router session created.');
console.log('\nChat started. Type your requests below.');
console.log("Commands: 'exit', 'quit', or 'q' to end\n");

try {
  const first = await run(agent, 'What can you help me with?', { session: conversationSession });
  console.log(`Assistant: ${first.finalOutput}\n`);
} catch (e) {
  console.error('Error:', e instanceof Error ? e.message : e, '\n');
}

rl.prompt();

rl.on('line', async (userInput) => {
  const text = userInput.trim();

  if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
    console.log('Goodbye!');
    rl.close();
    process.exit(0);
  }

  if (!text) {
    rl.prompt();
    return;
  }

  try {
    const result = await run(agent, text, { session: conversationSession });
    console.log(`\nAssistant: ${result.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();
});

rl.on('close', () => {
  console.log('\n👋 Session ended.');
  process.exit(0);
});
What's happening:
  • The program prints a session URL that you visit to authorize Slackbot.
  • After authorization, the chat begins.
  • Each message you type is processed by the agent using run().
  • The responses are printed to the console.
  • Typing exit, quit, or q cleanly ends the chat.

Complete Code

Here's the complete code to get you started with Slackbot and OpenAI Agents SDK:

import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});

async function main() {
  // Create Tool Router session
  const session = await composio.create(userId as string, {
    toolkits: ['slackbot'],
  });
  const mcpUrl = session.mcp.url;

  // Configure agent with MCP tool
  const agent = new Agent({
    name: 'Assistant',
    model: 'gpt-5',
    instructions:
      'You are a helpful assistant that can access Slackbot. Help users perform Slackbot operations through natural language.',
    tools: [
      hostedMcpTool({
        serverLabel: 'tool_router',
        serverUrl: mcpUrl,
        headers: { 'x-api-key': composioApiKey },
        requireApproval: 'never',
      }),
    ],
  });

  // Keep conversation state across turns
  const conversationSession = new OpenAIConversationsSession();

  // Simple CLI
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: 'You: ',
  });

  console.log('\nComposio Tool Router session created.');
  console.log('\nChat started. Type your requests below.');
  console.log("Commands: 'exit', 'quit', or 'q' to end\n");

  try {
    const first = await run(agent, 'What can you help me with?', { session: conversationSession });
    console.log(`Assistant: ${first.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();

  rl.on('line', async (userInput) => {
    const text = userInput.trim();

    if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
      console.log('Goodbye!');
      rl.close();
      process.exit(0);
    }

    if (!text) {
      rl.prompt();
      return;
    }

    try {
      const result = await run(agent, text, { session: conversationSession });
      console.log(`\nAssistant: ${result.finalOutput}\n`);
    } catch (e) {
      console.error('Error:', e instanceof Error ? e.message : e, '\n');
    }

    rl.prompt();
  });

  rl.on('close', () => {
    console.log('\nSession ended.');
    process.exit(0);
  });
}

main().catch((err) => {
  console.error('Fatal error:', err);
  process.exit(1);
});

Conclusion

This was a starter code for integrating Slackbot MCP with OpenAI Agents SDK to build a functional AI agent that can interact with Slackbot.

Key features:

  • Hosted MCP tool integration through Composio's Tool Router
  • SQLite session persistence for conversation history
  • Simple async chat loop for interactive testing
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.
TOOLS & TRIGGERS

Supported Tools and Triggers

Every Slackbot action and event your agent gets out of the box.

Add call participants

Registers new participants added to a Slack call.

Add reaction to message

Adds a specified emoji reaction to an existing message in a Slack channel, identified by its timestamp; does not remove or retrieve reactions.

Add a remote file

Adds a reference to an external file (e.

Archive a Slack conversation

Archives a Slack conversation by its ID, rendering it read-only and hidden while retaining history, ideal for cleaning up inactive channels; be aware that some channels (like #general or certain DMs) cannot be archived and this may impact connected integrations.

Close conversation channel

Closes a Slack direct message (DM) or multi-person direct message (MPDM) channel, removing it from the user's sidebar without deleting history; this action affects only the calling user's view.

Create a reminder

Creates a Slack reminder with specified text and time; time accepts Unix timestamps, seconds from now, or natural language (e.

Create Slack Canvas

Creates a new Slack Canvas with the specified title and optional content.

Create channel

Initiates a public or private channel-based conversation in a Slack workspace.

Create a Slack user group

Creates a new User Group (often referred to as a subteam) in a Slack workspace.

Customize URL unfurl

Customizes URL previews (unfurling) in a specific Slack message using a URL-encoded JSON in `unfurls` to define custom content or remove existing previews.

Delete Slack Canvas

Deletes a Slack Canvas permanently and irreversibly.

Delete a file by ID

Permanently deletes an existing file from a Slack workspace using its unique file ID; this action is irreversible and also removes any associated comments or shares.

Delete file comment

Deletes a specific comment from a file in Slack; this action is irreversible.

Delete a Slack reminder

Deletes an existing Slack reminder, typically when it is no longer relevant or a task is completed; this operation is irreversible.

Delete a message from a chat

Deletes a message, identified by its channel ID and timestamp, from a Slack channel, private group, or direct message conversation; the authenticated user or bot must be the original poster.

Delete scheduled chat message

Deletes a pending, unsent scheduled message from the specified Slack channel, identified by its `scheduled_message_id`.

Disable a Slack user group

Disables a specified, currently enabled Slack User Group by its unique ID, effectively archiving it by setting its 'date_delete' timestamp; the group is not permanently deleted and can be re-enabled.

Download Slack file

Tool to download Slack file content and convert it to a publicly accessible URL.

Edit Slack Canvas

Edits a Slack Canvas with granular control over content placement.

Share file public url

Enables public sharing for an existing Slack file by generating a publicly accessible URL; this action does not create new files.

Enable a user group

Enables a disabled User Group in Slack using its ID, reactivating it for mentions and permissions; this action only changes the enabled status and cannot create new groups or modify other properties.

End a call

Ends an ongoing Slack call, identified by its ID (obtained from `calls.

Fetch conversation history

Fetches a chronological list of messages and events from a specified Slack conversation, accessible by the authenticated user/bot, with options for pagination and time range filtering.

Fetch item reactions

Fetches reactions for a Slack message, file, or file comment.

Retrieve conversation replies

Retrieves replies to a specific parent message in a Slack conversation, using the channel ID and the parent message's timestamp (`ts`).

Fetch team info

Fetches comprehensive metadata about the current Slack team, or a specified team if the provided ID is accessible.

Find channels

Find channels in a Slack workspace by any criteria - name, topic, purpose, or description.

Lookup users by email

Retrieves the Slack user object for an active user by their registered email address; requires the users:read.

Find users

Find users in a Slack workspace by any criteria - email, name, display name, or other text.

Fetch bot user information

Fetches information for a specified, existing Slack bot user; will not work for regular user accounts or other integration types.

Retrieve call information

Retrieves a point-in-time snapshot of a specific Slack call's information.

Get reminder information

Retrieves detailed information for an existing Slack reminder specified by its ID; this is a read-only operation.

Get remote file

Retrieve information about a remote file added to Slack via the files.

Retrieve team profile details

Retrieves all profile field definitions for a Slack team, optionally filtered by visibility, to understand the team's profile structure.

Get team DND status

Retrieves a user's current Do Not Disturb status.

Retrieve user presence

Retrieves a Slack user's current real-time presence (e.

Invite users to a Slack channel

Invites users to an existing Slack channel using their valid Slack User IDs.

Join conversation by channel id

Joins an existing Slack conversation (public channel, private channel, or multi-person direct message) by its ID, if the authenticated user has permission.

Leave conversation channel

Leaves a Slack conversation given its channel ID; fails if leaving as the last member of a private channel or if used on a Slack Connect channel.

List all channels

Lists conversations available to the user with various filters and search options.

List all users

Retrieves a paginated list of all users with profile details, status, and team memberships in a Slack workspace; data may not be real-time.

List conversations

List conversations (channels/DMs) accessible to a specified user (or the authenticated user if no user ID is provided), respecting shared membership for non-public channels.

List team custom emojis

Retrieves all custom emojis for the Slack workspace (image URLs or aliases), not standard Unicode emojis; does not include usage statistics or creation dates.

List Slack files

Lists files and their metadata within a Slack workspace, filterable by user, channel, timestamp, or type; returns metadata only, not file content.

List pinned items in a channel

Retrieves all messages and files pinned to a specified channel; the caller must have access to this channel.

List reminders

Lists all reminders with their details for the authenticated Slack user; returns an empty array if no reminders exist (valid state, not an error).

List remote files

Retrieve information about a team's remote files.

List all users in a user group

Retrieves a list of all user IDs within a specified Slack user group, with an option to include users from disabled groups.

List user groups

Lists user groups in a Slack workspace, including user-created and default groups; results for large workspaces may be paginated.

List user reactions

Lists all reactions added by a specific user to messages, files, or file comments in Slack, useful for engagement analysis when the item content itself is not required.

Lookup Canvas Sections

Looks up section IDs in a Slack Canvas for use with targeted edit operations.

Open DM

Opens or resumes a Slack direct message (DM) or multi-person direct message (MPIM) by providing either user IDs or an existing channel ID.

Pin an item to a channel

Pins a message to a specified Slack channel; the message must not already be pinned.

Remove call participants

Registers participants removed from a Slack call.

Remove reaction from item

Removes an emoji reaction from a message, file, or file comment in Slack.

Remove remote file

Removes the Slack reference to an external file (which must have been previously added via the remote files API), specified by either its `external_id` or `file` ID (one of which is required), without deleting the actual external file.

Remove user from conversation

Removes a specified user from a Slack conversation (channel); the caller must have permissions to remove users and cannot remove themselves using this action.

Rename a conversation

Renames a Slack channel, automatically adjusting the new name to meet naming conventions (e.

Retrieve conversation information

Retrieves metadata for a Slack conversation by ID (e.

Get conversation members

Retrieves a paginated list of active member IDs (not names, emails, or presence) for a specified Slack public channel, private channel, DM, or MPIM.

Retrieve user DND status

Retrieves a Slack user's current Do Not Disturb (DND) status to determine their availability before interaction; any specified user ID must be a valid Slack user ID.

Retrieve detailed file information

Retrieves detailed metadata and paginated comments for a specific Slack file ID; does not download file content.

Retrieve detailed user information

Retrieves comprehensive information for a valid Slack user ID, excluding message history and channel memberships.

Retrieve user profile information

Retrieves profile information for a specified Slack user (defaults to the authenticated user if `user` ID is omitted); a provided `user` ID must be valid.

Revoke a file's public url

Revokes a Slack file's public URL, making it private; this is a no-op if not already public and is irreversible.

Schedule message

Schedules a message to a Slack channel, DM, or private group for a future time (`post_at`), requiring `text`, `blocks`, or `attachments` for content; scheduling is limited to 120 days in advance.

Search all content

Tool to search all messages and files.

Search messages

Workspace‑wide Slack message search with date ranges and filters.

Send ephemeral message

Sends an ephemeral message visible only to the specified `user` in a channel; other channel members cannot see it.

Share a me message in a channel

Sends a 'me message' (e.

Send message

Posts a message to a Slack channel, DM, or private group; requires at least one content field (`markdown_text`, `text`, `blocks`, or `attachments`) — omitting all causes a `no_text` error.

Set a conversation's purpose

Sets the purpose (a short description of its topic/goal, displayed in the header) for a Slack conversation; the calling user must be a member.

Set conversation read cursor

Marks a message, specified by its timestamp (`ts`), as the most recently read for the authenticated user in the given `channel`, provided the user is a member of the channel and the message exists within it.

Set conversation topic

Sets or updates the topic for a specified Slack conversation.

Set user presence

Manually sets a user's Slack presence, overriding automatic detection; this setting persists across connections but can be overridden by user actions or Slack's auto-away (e.

Share a remote file in channels

Shares a remote file, which must already be registered with Slack, into specified Slack channels or direct message conversations.

Start call

Registers a new call in Slack using `calls.

Unarchive channel

Reverses conversation archival.

Unpin message from channel

Unpins a message, identified by its timestamp, from a specified channel if the message is currently pinned there; this operation is destructive.

Update call information

Updates the title, join URL, or desktop app join URL for an existing Slack call identified by its ID.

Update an existing remote file

Updates metadata or content details for an existing remote file in Slack; this action cannot upload new files or change the fundamental file type.

Update a Slack message

Updates a Slack message, identified by `channel` ID and `ts` timestamp, by modifying its `text`, `attachments`, or `blocks`; provide at least one content field, noting `attachments`/`blocks` are replaced if included (`[]` clears them).

Update Slack user group

Updates an existing Slack User Group, which must be specified by an existing `usergroup` ID, with new optional details such as its name, description, handle, or default channels.

Update user group members

Replaces all members of an existing Slack User Group with a new list of valid user IDs.

Upload or create a file in Slack

Upload files, images, screenshots, documents, or any media to Slack channels or threads.

FAQ

Frequently asked questions

With a standalone Slackbot MCP server, the agents and LLMs can only access a fixed set of Slackbot tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Slackbot and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. OpenAI Agents SDK fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Slackbot tools.

Yes, absolutely. You can configure which Slackbot scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Slackbot data and credentials are handled as safely as possible.

Start with Slackbot.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Slackbot tool your agent needs.Free to start.

Start building