Skip to main content

01 — Discord Bot

A Discord bot with memory that remembers conversations per user.
import asyncio

from definable.agent import Agent
from definable.agent.interface import DiscordInterface
from definable.memory import Memory, SQLiteStore
from definable.model import OpenAIChat

memory = Memory(store=SQLiteStore("./discord_memory.db"))

agent = Agent(
  model=OpenAIChat(id="gpt-4o"),
  instructions="You are a helpful Discord bot with persistent memory.",
  memory=memory,
)

discord = DiscordInterface(
  agent=agent,
  bot_token="your-discord-bot-token",
)

asyncio.run(discord.serve_forever())

Full source

definable/examples/interfaces/01_discord_bot.py

Voice Call Examples

Managed Mode (Twilio ConversationRelay)

The simplest voice agent — Twilio handles STT/TTS natively.
import asyncio
from definable.agent import Agent
from definable.agent.interface.call import CallInterface
from definable.agent.runtime import AgentRuntime

agent = Agent(
  model="openai/gpt-4o-mini",
  instructions="You are a helpful phone agent. Keep responses concise.",
)

call = CallInterface(
  agent=agent,
  provider="twilio",
  phone_number="+15551234567",
  pipeline="managed",
  welcome_message="Hello! How can I help you today?",
)

runtime = AgentRuntime(agent, interfaces=[call], host="0.0.0.0", port=8000)
asyncio.run(runtime.start())

Full source

definable/examples/call/01_managed_voice_agent.py

Cascading Mode (Deepgram STT + Cartesia TTS)

Full control over STT and TTS providers.

Full source

definable/examples/call/02_cascading_pipeline.py

Realtime Mode (OpenAI Speech-to-Speech)

Lowest latency — audio flows directly to OpenAI’s Realtime API.

Full source

definable/examples/call/03_realtime_pipeline.py

Plivo + Cascading Pipeline

Using Plivo as the telephony provider with Deepgram STT and Cartesia TTS.

Full source

definable/examples/call/04_plivo_cascading.py

Slack Bot Examples

Minimal Slack Bot

A Slack bot using Socket Mode — the simplest way to get started.
import asyncio
import os
from definable.agent import Agent
from definable.agent.interface import SlackInterface

agent = Agent(
  model="openai/gpt-4o-mini",
  instructions="You are a helpful Slack assistant. Keep responses concise.",
)

interface = SlackInterface(
  agent=agent,
  bot_token=os.environ["SLACK_BOT_TOKEN"],
  app_token=os.environ["SLACK_APP_TOKEN"],
)

asyncio.run(interface.serve_forever())

Full source

definable/examples/slack/01_slack_bot.py

Slack Bot with Tools and Memory

A full-featured Slack agent with tools, memory, and completion reactions.

Full source

definable/examples/slack/03_slack_with_tools.py

Slack HTTP Events API

Production deployment using HTTP Events API with AgentRuntime.

Full source

definable/examples/slack/02_slack_webhook.py

02 — Multi-Interface with Identity Resolution

Run Telegram and Discord simultaneously with a shared identity resolver, so the same user is recognized across platforms.
import asyncio

from definable.agent import Agent
from definable.agent.interface import (
    TelegramInterface,
    DiscordInterface,
    SQLiteIdentityResolver,
    serve,
)
from definable.memory import Memory, SQLiteStore
from definable.model import OpenAIChat

memory = Memory(store=SQLiteStore("./multi_memory.db"))
resolver = SQLiteIdentityResolver(db_path="./identity.db")

agent = Agent(
  model=OpenAIChat(id="gpt-4o"),
  instructions="You are a helpful multi-platform bot.",
  memory=memory,
)

telegram = TelegramInterface(
  agent=agent,
  bot_token="telegram-token",
)

discord = DiscordInterface(
  agent=agent,
  bot_token="discord-token",
)

asyncio.run(serve(telegram, discord, name="my-bot", identity_resolver=resolver))

Full source

definable/examples/interfaces/02_multi_interface.py

03 — Desktop Control via Telegram

Control a macOS desktop agent remotely through Telegram. Combines the Desktop interface with Telegram for remote desktop automation.

Full source

definable/examples/interfaces/03_desktop_control_via_telegram.py

04 — InterfaceGateway with Telegram

Use InterfaceGateway for centralized multi-channel coordination — shared hooks, per-interface status tracking, lifecycle events, and cross-platform identity linking.

Full source

definable/examples/interfaces/04_gateway_telegram.py