Connect an AI agent to Slack
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.
- Go to Slack API and click Create New App > From scratch and provide an app name and a workspace.
- In the App credentials page, copy the Client ID and Client Secret.
- 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
.
- Redirect URL
- 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.
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
Add icon > Add a connection.
-
Enter a user-friendly Connection name.
-
Select a Connection type of HTTP.
-
Select OAuth User to Machine Per User.
-
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
- Host:
-
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
- Token endpoint:
-
After creating the connection, click Login to authenticate the 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
Next steps
- Learn more about AI agent tools
- Review Slack API documentation for additional capabilities