Skip to main content

Connect an AI agent to Slack

Preview

This feature is in Public Preview.

Learn how to create an AI agent that can post messages to Slack using HTTP Unity Catalog connections. This page demonstrates User-to-Machine authentication for external services, allowing your agent to interact with Slack.

Requirements

Before you begin, verify you have:

  • Workspace admin privileges to create Unity Catalog connections.
  • Access to a Slack workspace where you can create apps.
  • The ability to create Unity Catalog functions in your workspace.

Create a Slack app

Create a Slack app and configure permissions so your agent can use the app to post on your behalf.

  1. Go to Slack API and click Create New App > From scratch and provide an app name and a workspace.
  2. In the App credentials page, copy the Client ID and Client Secret.
  3. In the OAuth & Permissions section, add the following:
    • Redirect URL https://<your_databricks_workspace_host_URL>.com/login/oauth/http.html.
    • Bot token scope, chat:write.
  4. Click Install to Workspace and authorize the app.

Create the Unity Catalog HTTP connection

A Unity Catalog connection provides your agent a secure and reusable way to connect to the Slack app. To learn more about HTTP connections, see Connect to external HTTP services.

  1. In your Databricks workspace, click Data icon. Catalog.

  2. At the top of the Catalog pane, click the Add or plus icon Add icon > Add a connection.

  3. Enter a user-friendly Connection name.

  4. Select a Connection type of HTTP.

  5. Select OAuth User to Machine Per User.

  6. On the Authentication page, enter the following connection properties for the HTTP connection:

    • Host: https://slack.com
    • Port: 443
    • Secret: <YOUR_CLIENT_SECRET>
    • Client ID: <YOUR_CLIENT_ID>
    • Authorization endpoint: https://slack.com/oauth/v2/authorize
    • OAuth Scope: chat:write
    • Token endpoint: https://slack.com/api/oauth.v2.access
  7. On the Connection details page, enter the following:

    • Token endpoint: https://slack.com/api/oauth.v2.access
    • Base path: /
    • OAuth credential exchange method: Header and body
  8. After creating the connection, click Login to authenticate the connection.

    Login to Slack connection

Agent code example

After you create the Slack app and Unity Catalog connection, use the code in the following notebook to define an agent that uses those resources to post messages to Slack.

Slack messaging agent tool

Open notebook in new tab

Next steps