snippets_py
Integration
New integration from credential
app = yepcode.integration.slack("credential-slug")
New integration from plain authentication data
from slack_bolt import App
app = App(token="your-token", signing_secret="your-signing-secret")
Using the Web API
Lists channels
channels = app.client.conversations_list()
print(channels)
Retrieve messages
result = app.client.conversations_history(
channel="channel_id"
)
messages = result["messages"]
print(messages)
Post a message
app.client.chat_postMessage(
channel="channel_id",
text="Test bot message!"
)
Upload a file
import io
file_content = """
Some multiline file content
Other line
"""
app.client.files_upload_v2(
channel="channel_id",
initial_comment="Here's the file :smile:",
file=io.BytesIO(file_content.encode("utf-8")),
filename="filename.txt"
)