Slack
Available to teams and users on all plans
Want to get started right away?
Jump right into Deepnote and view an example of using Slack to deliver updates on scheduled notebook runs here.
Slack is the collaboration hub that brings the right people, information, and tools together to get work done. This guide walks you through using Slack to deliver notifications at different points of your data workflows on Deepnote (like updating you on the status of scheduled notebook runs).
Deepnote and Slack

How to set it up

The first step in integrating Slack with your Deepnote notebooks is creating a Slack app and getting your app's token. All you need to do to get started is:
  1. 1.
    Create a Slack app by clicking the Create App button here.
  2. 2.
    Copy the Slack token of your new app. It should start with "xoxb", for example xoxb-not-a-real-token-this-will-not-work.
  3. 3.
    Store the token in a variable (such as SLACK_TOKEN). If you'd like to keep your data secure, consider storing the token as an environment variable. Environment variables in Deepnote are encrypted and provide a secure way of storing sensitive data.
  4. 4.
    Install the slack_sdk Python package by running !pip install slack_sdk.

How to use

Once you've created your Slack app and installed the slack_sdk Python package, sending notifications via Slack becomes rather straightforward. The code below sends a notification into the #general channel informing everyone in that channel of a successful run.
1
import os
2
from datetime import datetime
3
import slack_sdk
4
​
5
CHANNEL = '#general' # Insert the name of channel here
6
USERNAME = 'Deepnote Bot'
7
ICON = 'https://avatars.githubusercontent.com/u/45339858?s=280&v=4' # This is a URL pointing to the icon of your bot.
8
today = datetime.today().strftime('%B %d, %Y at %H:%M UTC')
9
MESSAGE_TEXT = f'Experiment status: Success!\nLast run: {today}' # This is a sample message. Replace with your own text.
10
​
11
def post_message_to_slack(slack_token, text, channel, blocks=None):
12
try:
13
print('Sending message...')
14
# Connect to the Slack client via token
15
client = slack_sdk.WebClient(token=SLACK_TOKEN)
16
​
17
# Post the Slack message
18
request = client.chat_postMessage(
19
text=text,
20
channel=channel,
21
blocks=blocks,
22
icon_url=ICON,
23
username=USERNAME
24
)
25
print('Message was sent successfully.')
26
return request
27
​
28
# Print error
29
except Exception as e:
30
print(f'Error: {e}')
31
​
32
request = post_message_to_slack(SLACK_TOKEN, MESSAGE_TEXT, CHANNEL)
Copied!
Using the function above to send a message will produce a Slack notification that is going to look a little something like this:
Slack notification from Deepnote

Next steps

Jump right into Deepnote & view an example of sending scheduled notebook run Slack updates here. You can also save yourself some setup work by hitting Duplicate button in the top-right corner to start exploring on your own!
Still need help?
Deepnote's community of over 5,000 data enthusiasts and professionals is always there for you. Post any questions into the Q&A channel here.