Haijun Platform Docs
ID

Introduction

You'll wrap the agent from data_analyst_agent.ipynb in a Slack bot built with Bolt for Python, Slack's official framework for building apps. Mention the bot with a question and a CSV attachment to get a narrative report posted back to the thread. Follow-up messages continue the same session.

ding-top:12px;padding-inline:12px;padding-bottom:12px;tab-size:4">

user: @databot what's driving Q1 revenue? [sales.csv]

│

▼

bot uploads the CSV and starts an agent session

│

▼

bot streams the agent's progress back to the thread

│

▼

bot posts the finished report to the thread

What you'll learn

OAuth & Permissions

→ copy the Bot User OAuth Token (

xoxb-...

)

Basic Information → App-Level Tokens

→ generate one with scope

connections:write

(

xapp-...

)

In a channel you want the bot in, run /invite @databot.

archive sessions when threads go stale.

thread_sessions: dict[str, str] = {}

mrkdwn = SlackMarkdownConverter()

1. Start a session when the bot is mentioned

text-indent:-12ch"> app.client.chat_postMessage(

channel=channel,

thread_ts=thread_ts,

text=f"Session terminated unexpectedly. Trace: {trace}",

)

return

Turn is done. Post the summary, then upload any generated files.

if summary:

text = mrkdwn.convert(summary)

if len(text) > 3900: # Slack text limit ~4000 chars

text = text[:3900] + "\n_(truncated)_"

app.client.chat_postMessage(channel=channel, thread_ts=thread_ts, text=text)

outputs = client.beta.files.list(scope_id=session_id, betas=["managed-agents-2026-04-01"])

for f in outputs.data:

if not f.downloadable:

continue

content = client.beta.files.download(f.id).read()

app.client.files_upload_v2(

channel=channel, thread_ts=thread_ts, filename=f.filename, content=content

)

3. Handle follow-ups in the same session

On this page
What you'll learn1. Start a session when the bot is mentioned3. Handle follow-ups in the same session