Slack is a vital part of many organizations today as a messaging app that aims to increase productivity in various ways. In fact, Slack is more than just a messaging app for many teams thanks to its feature rich platform and cool integrations with external apps or sources. This is exactly what brings Oracle Autonomous Database (ADB) and Slack together in this blog post. Have you ever wanted to send alerts or notifications to your team when certain scheduler jobs are completed, or have you ever needed to share the result of a query as a report with your team? If you are interested in any of these use cases, you are at the right place. In this blog post, we are going to explore ADB’s new cool integration with Slack that lets you send messages, alerts, or query results to your Slack channels.
Before we get started, here are the prerequisites for this feature:
- Slack account and workspace. If your organization uses Slack, you should already have these.
- Slack app. Slack comes with various built-in productivity apps that you can add to your channels or workspaces. For this use case, you want to create your own app that has the following permission scopes: “channels:read“, “chat:write” and “files:write“. This app will essentially act as a bot to push those alerts or notifications to your channels. When you are creating your own Slack app, take a note of your bot token as you will need it later.
- Slack channel. As mentioned earlier, your Slack app will be posting the alerts or notifications that come from ADB to your designated channel. For this purpose, you need to have a Slack channel in which you will add the app you created in the previous step.
Now that we have a Slack channel and a Slack app added to that channel, we are ready go ahead with this demonstration. Here are the steps we’ll follow:
- Create a credential object for our Slack app
- Send a message to our Slack channel
- Send a query output to our Slack channel
- Confirm the receival of the messages in our Slack channel
Create a credential object for our Slack app
We first need to create a credential object in our ADB instance so that it can authenticate itself against the Slack app we created. For this credential, we need to use SLACK_TOKEN as our username and the Slack app’s bot token as our password:
begin
dbms_cloud.create_credential(
credential_name => 'SLACK_CRED',
username => 'SLACK_TOKEN',
password => 'xo****************************I');
end;
/
Send a message to our Slack channel
I have a Slack channel called ‘ctuzla_channel’ in which I added my Slack app called ‘ADBS Notifications’. In this step, we are going to send a simple message in plain text using the DBMS_CLOUD_NOTIFICATIONS.SEND_MESSAGE procedure. One thing to note here is the params parameter where we specify our channel id.
begin
dbms_cloud_notification.send_message(
provider => 'slack',
credential_name => 'SLACK_CRED',
message => 'Hello World!',
params => json_object('channel' value 'C04*****Y'));
end;
/
Send a query output to our Slack channel
Next, we are going to share the instance and tenancy details of our Autonomous Database in our channel by querying the cloud_identity column of the v$pds view. For this use case, we will be using the DBMS_CLOUD_NOTIFICATIONS.SEND_MESSAGE procedure. Similar to the previous use case, we again need to provide our channel id as well as the format of the output file (which can be CSV or JSON).
begin
dbms_cloud_notification.send_data(
provider => 'slack',
credential_name => 'SLACK_CRED',
query => 'select cloud_identity from v$pdbs',
params => json_object('channel' value 'C04*****Y',
'type' value 'csv')
);
end;
/
Confirm the receival of the messages in our Slack channel
Let’s check our channel to see if we have successfully received both notifications from our Autonomous Database:

That was easy, wasn’t it? To summarize, Autonomous Database now supports sending alerts, messages, or query results directly to your Slack channels to boost your productivity even more. You can use this feature to send messages regarding certain database events or share reports that are created based on queries you execute in your ADB instance. If you’d like to learn more about this new integration, please check out our documentation.
