Getting started
Working with files
Coding and analysis tools
Collaboration
Security and privacy
Deepnote for education
Additional resources
Slack
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).
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:
- Create a Slack app by clicking the
Create App
button here. - Copy the Slack token of your new app. It should start with "xoxb", for example
xoxb-not-a-real-token-this-will-not-work
. - 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. - 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.
import os
from datetime import datetime
import slack_sdk
CHANNEL = '#general' # Insert the name of channel here
USERNAME = 'Deepnote Bot'
ICON = 'https://avatars.githubusercontent.com/u/45339858?s=280&v=4' # This is a URL pointing to the icon of your bot.
today = datetime.today().strftime('%B %d, %Y at %H:%M UTC')
MESSAGE_TEXT = f'Experiment status: Success!\nLast run: {today}' # This is a sample message. Replace with your own text.
def post_message_to_slack(slack_token, text, channel, blocks=None):
try:
print('Sending message...')
# Connect to the Slack client via token
client = slack_sdk.WebClient(token=SLACK_TOKEN)
# Post the Slack message
request = client.chat_postMessage(
text=text,
channel=channel,
blocks=blocks,
icon_url=ICON,
username=USERNAME
)
print('Message was sent successfully.')
return request
# Print error
except Exception as e:
print(f'Error: {e}')
request = post_message_to_slack(SLACK_TOKEN, MESSAGE_TEXT, CHANNEL)
Using the function above to send a message will produce a Slack notification that is going to look a little something like this:
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.