Skip to content

Slack apps: using the VIDAI Control Plane as the backend

Slack bots (built with Bolt for Python / JavaScript, Workflow Builder webhook steps, or any custom Events API handler) call an LLM inside their message-handler code. Point that call at the control plane and every reply your bot generates flows through us.

TL;DR (Bolt for Python)

from slack_bolt import App
from openai import OpenAI

app = App(token="xoxb-...", signing_secret="...")
client = OpenAI(
    base_url="https://your-vidai-server.example.com/v1",
    api_key="your-vidai-key",
)

@app.event("app_mention")
def handle_mention(event, say):
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": event["text"]}],
    )
    say(resp.choices[0].message.content)

app.start(3000)

Prerequisites

  • A Slack workspace with permission to install a bot.
  • A Slack app created at api.slack.com with the app_mentions:read and chat:write scopes.
  • Control plane base URL and an API key from API Keys.
  • A model registered on the Models page.

Storing the key

Load openai_api_key from your bot's runtime secret store (Kubernetes Secret, AWS Secrets Manager, .env on a Fly.io/Render deploy, etc.). Don't paste it into your bot source.

Multi-turn conversations in threads

If your bot maintains conversation history per Slack thread:

history = {}   # thread_ts -> [ {role, content}, ... ]

@app.event("message")
def handle_thread(event, say):
    ts = event.get("thread_ts", event["ts"])
    history.setdefault(ts, [])
    history[ts].append({"role": "user", "content": event["text"]})

    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=history[ts],
    )
    reply = resp.choices[0].message.content
    history[ts].append({"role": "assistant", "content": reply})
    say(text=reply, thread_ts=ts)

Each turn is a control-plane request on Request Logs.

Attribution

One VIDAI API key per Slack app. If you deploy the bot to several workspaces, mint one key per workspace so the Chargeback tab splits per customer.

Slack Workflow Builder

Workflow Builder's webhook step can POST to /v1/chat/completions directly. Payload shape and headers match Zapier's Webhooks example.

Verify it works

Mention your bot in a channel:

@your-bot reply with exactly: ok

The bot replies. A row appears on Request Logs.

If something's off

Raise an issue at github.com/vidaiUK/vidai-quickstart/issues with the bot's handler code (masking the key) and the failing Slack message. We'll get it sorted.

Where to go next