Skip to main content

Slack

Connect Slack to Squid to send AI-powered messages

Slack connector functionality

The Slack connector supports:

  • Sending messages to channels, groups, and individual users
  • Interacting with Squid AI agents directly in Slack via SlackBot
  • Reading conversations into a knowledge base for intelligent search and summaries

Configuring the Slack connector

Squid connects to a Slack application to send and read messages in your Slack workspace.

Creating a Slack application

  1. Navigate to the Slack applications landing page.
  2. Click Create New App and provide a meaningful App Name and the corresponding Slack workspace.

Adding the Slack connector to your Squid application

  1. Navigate to the Squid Console and select the Connectors tab.

  2. Switch to the Available Connectors tab and add a Slack connector.

  3. The configuration details can all be found on the settings page of the Slack application you just created:

    Connector ID: A meaningful string that uniquely identifies the connector in the code.

    App ID: The ID of the Slack application, which can be found on the Basic Information tab of your Slack app's settings.

    Client ID: The Client ID of the Slack application, which can also be found on the Basic Information tab.

    Verification Token: The Verification Token of the Slack app, which can be found on the Basic Information tab.

    Client Secret: The Client Secret of the Slack app, which can be found on the Basic Information tab.

    Signing Secret: The Signing Secret of the Slack app, which can be found on the Basic Information tab.

    Squid Console API overview

    Bot User OAuth Token: The Bot User OAuth token of the Slack application, which can be found on the OAuth & Permissions tab. This token is used to authenticate the requests to the Slack API.

    Squid Console API overview

    Index Channels: Whether Squid should read all messages (from the channels the bot is added to) to offer intelligent searches and summaries.

    Message History Limit: When messaging Squid via Slack, Squid will read this many prior messages to provide itself enough context to best answer the user.

  4. Navigate to the OAuth & Permissions tab and ensure that the following Bot Token Scopes are added:

    • app_mentions:read
    • channels:history
    • channels:join
    • channels:read
    • chat:write
    • chat:write.public
    • files:read
    • files:write
    • groups:history
    • groups:read
    • im:history
    • im:read
    • im:write
    • mpim:history
    • mpim:read
    • mpim:write
    • users:read
    • users:read.email

Using the Slack connector in your application

There are three ways to use the Slack connector in your application:

  1. Using the Agent Studio: In Agent Studio, add the Slack connector via Add Abilities > Slack. Learn more about abilities. You can then test sending messages in the Test Agent tab. For message searching, allow a couple of hours for Squid to index your Slack messages. Example messages:

    • Send a slack message saying "Hello!" to James - Where "James" is a Slack user
    • Post "The deployment was successful!" to the #devops channel
    • Search Slack for conversations about the product launch
    • Show me all discussions in the Engineering team about API design
    • Find messages in the Finance channel about budget planning
  2. Using the Squid SDK: If you are using the Squid SDK to create your AI agent, you can use the squid.ai().agent('AGENT_ID').ask() function to chat with your agent. Learn more here. Use the Slack connector by adding it in the connectedIntegrations option of the ask() function.

// Configuration to let the agent be aware of the Slack connector.
const config = {
connectedIntegrations: [{
integrationId: 'SLACK_CONNECTOR_ID',
integrationType: 'slack',
description: 'Call this connector whenever a user asks to send or search Slack messages',
}]
};

// Send a message.
await this.squid.ai().agent('AGENT_ID').ask('Send a slack message saying "Hello!" to the general channel', config);

// Search messages related to your search.
await this.squid.ai().agent('AGENT_ID').ask('Find messages in the Finance channel about budget planning.', config);
  1. Using the NPM package: If you use @squidcloud/slack-client, you can:
// Initialize the client.
const slackClient = SquidSlackClient(this.squid, 'SLACK_CONNECTOR_ID');

// Send a message.
await slackClient.sendMessage({
recipient: 'general',
recipientType: 'channel',
message: 'Hello!'
});

// Find messages related to your search.
await slackClient.searchMessages({
channelNames: 'general,random',
prompt: 'need help'
});

Interacting with AI Agents via SlackBot

To interact with AI agents directly in Slack, you can set up the SlackBot functionality in your Slack application as follows:

  1. In your Slack application settings, navigate to the Event Subscriptions tab.
  2. Toggle Enable Events to ON
  3. Under Request URL, enter the Webhook URL for Slack notification. The URL is in the following form:

https://[APP_ID]-[ENV_ID]-[DEVELOPER_ID].[REGION].squid.cloud/webhooks/slackNotification?agentId=[AGENT_ID]

Note

[DEVELOPER-ID] is only required when you are running backend locally. When deploying it to squid it is omitted, for example:

https://9kxp2nvqtcfflwazoe-dev.us-east-1.aws.squid.cloud/webhooks/slackNotification?agentId=quote-agent
Squid Console API overview
  1. Under Subscribe to Bot Events, add the following events:
    • message.im - to receive direct messages sent to the bot
    • app_mention - to receive messages where the bot is mentioned in channels

That's it! When users message your SlackBot, Squid will forward the prompt to the specified agent and respond directly in Slack.