Turn Codex into your personal operations engine: a Telegram-native AI assistant that can plan, execute, and follow through.
Dexbot brings Codex power into daily life and business workflows through Telegram. It gives you a practical way to run a full Codex agent from chat, with memory, skills, scheduling, files, voice, and topic-scoped sessions.
Why this project exists:
- Codex is one of the most capable coding/automation agents available.
- Existing Telegram agent stacks are often not optimized for Codex-native workflows.
- Dexbot is designed to make Codex usable as a real, always-available automation operator.
Important:
- Users bring their own Codex account/subscription (
codex loginon their machine). - Users bring their own Telegram bot token.
- This project is a bridge/runtime, not a shared hosted service.
git clone https://github.com/alanayoubi/Dexbot.git
cd Dexbot
npm install
npm run onboard
npm run startThen open the local dashboard:
http://127.0.0.1:8788
- Working memory (ephemeral, per turn):
- current goal, plan, assumptions, active constraints, tool result summary
- generated in runtime only, not persisted
- Session memory (persisted per chat/session):
memory/sessions/<chat>/<session>/session_summary.mdmemory/sessions/<chat>/<session>/session_key_facts.json
- Long-term canonical memory (human-auditable markdown):
memory/daily/YYYY-MM-DD.md(append-only)memory/MEMORY.mdmemory/USER.mdmemory/IDENTITY.mdmemory/SOUL.mdmemory/HEARTBEAT.mdmemory/TOOLS.md
- Long-term derived index (disposable/rebuildable):
- SQLite tables:
facts,episodes,documents,open_loops,contradictions - FTS/BM25:
facts_fts,episodes_fts,documents_fts - vector embeddings (deterministic local embeddings) for episode/document hybrid retrieval
- SQLite tables:
- Write pipeline (
retain -> reflect -> index) on every turn:- append daily journal entry
- extract important facts (max configured)
- extract major episode summaries (max configured)
- update session summary/key facts
- update curated memory files (
MEMORY.md,USER.md) - index files/chunks into
documents+ FTS + embeddings
- Retrieval pipeline (
hybrid -> filters -> rerank -> capped injection):- vector search on episodes
- keyword FTS search on facts/episodes/documents
- exact metadata/entity/tag matching
- confidence filter + recency bias + project bias
- reranked final memory injection with strict section caps and token cap
- Always-on personality/identity:
memory/IDENTITY.mdandmemory/SOUL.mdare silently applied on every turn via developer instructions- never shown to the user unless explicitly requested
- Heartbeat maintenance (scheduled, default every 24h):
- compress old daily logs into weekly summaries
- fact dedupe
- confidence decay for stale facts
- contradiction detection
- keep curated files compact
- Self-healing transport:
- automatic reconnect when app-server socket drops
- auto-respawn of
codex app-serverwhen unavailable - pending request recovery + retry path for transient disconnects
cp .env.example .env
npm install
npm run startDexbot now includes a local web dashboard so users can:
- chat with streaming updates from desktop (not only Telegram)
- upload files/images directly to Codex
- manage sessions/scopes
- run slash command features from chat (
/memory,/schedule,/skill,/heartbeat,/newsession,/restart,/autostart) - update
.envsettings from UI (Telegram IDs/chats/tokens and other env keys) - view runtime/account controls in a UI panel
Dashboard env settings:
DASHBOARD_ENABLED=true
DASHBOARD_HOST=127.0.0.1
DASHBOARD_PORT=8788
# Optional but recommended:
DASHBOARD_AUTH_TOKEN=<your-local-token>
If DASHBOARD_AUTH_TOKEN is set, dashboard API access is protected and authorized via secure local cookie.
Environment settings security:
- Secret keys are masked in UI and never returned in plaintext by settings APIs.
- Saving settings writes
.envatomically and enforceschmod 600. - Use “Restart after save” in dashboard settings to apply runtime changes immediately.
For guided onboarding (recommended for new users):
npm run onboardThe onboarding wizard:
- checks
codexis installed - checks
codex login statusand reports if you're already authenticated - can run
codex loginonly when you choose it - detects existing
.envsetup and shows current Telegram/security config - offers modes: keep current, update existing, or reset from scratch
- warns clearly about machine access risk and asks for explicit full-access confirmation
- lets users choose access profile: full, partial, read-only, or custom
- collects Telegram settings
- writes
.envand sets secure permissions (chmod 600)
Images are supported in both directions:
- send photo/image documents to the bot (vision input)
- bot can send image outputs back to Telegram when generated/fetched by Codex
Voice messages are supported with local Whisper. Default config expects whisper on your PATH.
You can tune model/language/timeouts with WHISPER_* env vars in .env.
For faster turnaround, persistent mode keeps the Whisper model loaded between messages (WHISPER_PERSISTENT=true).
YouTube/audio transcription with AssemblyAI is available via script:
npm run yt:transcribe -- "https://www.youtube.com/watch?v=VIDEO_ID"Requirements:
yt-dlpffmpegcurljqASSEMBLYAI_API_KEYin.env
The script downloads audio, converts it to WAV, uploads to AssemblyAI, polls completion, and writes:
data/transcripts/<timestamp>/transcript.txtdata/transcripts/<timestamp>/transcript.jsondata/transcripts/<timestamp>/report.md
/start/newsession/memory/heartbeat/schedule/skill/restart/autostart on|off|status/chatid/whoami
Also supported:
- Send a normal text message
- Send a photo or image document (optionally with caption prompt)
- Send a Telegram voice note (
voice) or audio file (audio); bot transcribes locally and responds without echoing transcript text
Skills are Codex-style capability packs stored as:
<skills-root>/<skill-name>/SKILL.md
Format matches modern skill conventions (OpenAI/Anthropic style): required SKILL.md with YAML frontmatter (name, description) and optional scripts/, references/, assets/ folders.
Default skills root is:
.agents/skills
Telegram command examples:
/skill list
/skill paths
/skill create sales-page | Build persuasive landing pages | Gather offer details, draft sections, include CTA options.
/skill show sales-page
/skill run sales-page | Create a hero + offer section for a fintech B2B page.
/skill delete sales-page
You can also trigger a skill directly in normal chat with:
$sales-page <task>
Skill creation via command:
/skill create <name> | <description> | <instructions>
Natural-language creation is also supported through Codex intent (not simple keyword automation). If the intent/name is unclear, the assistant should ask follow-up questions before creating anything.
Use /schedule to make the bot proactive in the current chat/topic scope.
Examples:
/schedule add daily 09:00 | Send my morning report: priorities, open loops, and blockers.
/schedule add cron 0 18 * * 1-5 | Send end-of-day summary with decisions and pending items.
/schedule add heartbeat 13:30 | Check in with me and ask for my top focus right now.
/schedule list
/schedule pause 3
/schedule resume 3
/schedule run 3
/schedule remove 3
Notes:
- Schedule scope is topic-aware (
topic_id): each topic has isolated jobs. - Default timezone is local machine timezone (override per job with
tz=Area/City). /heartbeatremains memory-maintenance; proactive pings use/schedule ....- Natural-language schedule intents are supported (e.g., "set a daily schedule at 9am to send my morning report").
- Set
WHISPER_PERSISTENT=trueto avoid model reload on every clip - Use a smaller/faster model like
WHISPER_MODEL=baseorWHISPER_MODEL=tiny - Set
WHISPER_LANGUAGE=en(or your language) to skip repeated language detection
Dexbot supports multiple Codex access profiles during onboarding:
fullCODEX_SANDBOX=danger-full-accessCODEX_APPROVAL_POLICY=never- Highest power, highest risk. Recommended only on isolated machines.
partialCODEX_SANDBOX=workspace-writeCODEX_APPROVAL_POLICY=on-request- Good balance for most users.
read-onlyCODEX_SANDBOX=read-onlyCODEX_APPROVAL_POLICY=on-request- Safer mode for exploration and audits.
custom- You choose sandbox/approval manually.
Risk notice:
- Any high-access configuration can execute impactful commands.
- Use at your own risk and isolate this runtime from sensitive environments.
Yes, each person can use their own Codex account/subscription with this project.
How auth works:
- This bridge uses the local Codex CLI on that machine.
- Each user authenticates locally with
codex login(ChatGPT login flow or API key flow). - The bridge then uses that local logged-in Codex identity when running
codex app-server.
Branding:
- Set
BOT_APP_NAME(defaultDexbot) to customize bot-facing app name text.
Recommended distribution flow:
- Publish this repo to GitHub (without
.env). - User clones the repo.
- User runs
npm install. - User runs
npm run onboard. - User runs
npm run start.
Publish to GitHub (maintainer flow):
brew install gh
gh auth login --web
bash scripts/publish-github.sh <owner/repo> publicOr with npm:
npm run publish:github -- <owner/repo> publicSecurity reminder for shared installs:
- Keep
.envout of git. - Use strict allowlists (
ALLOWED_TELEGRAM_USER_IDS, optionalALLOWED_TELEGRAM_CHAT_IDS). - Keep
.envmode at600.
Dexbot uses a dual-license model:
- Open-source:
AGPL-3.0-only(seeLICENSE) - Commercial: available by separate agreement (see
COMMERCIAL_LICENSE.md)
What this means:
- If you use Dexbot under AGPL, commercial use is allowed only under AGPL terms and obligations.
- If you need proprietary/closed-source or special commercial terms, request a commercial license.
Brand protection:
- The code is licensed as above, but the
Dexbotname/brand is protected separately. - See
TRADEMARK_POLICY.md.
- Access gate is user-ID based using
ALLOWED_TELEGRAM_USER_IDS. - You can additionally lock chat IDs with
ALLOWED_TELEGRAM_CHAT_IDS. TELEGRAM_PRIVATE_ONLY=trueblocks group/channel usage (recommended).- Secrets in chat (API keys/tokens/password-like strings) are redacted before memory/db persistence.
.envis used for runtime secrets/config and is gitignored.
You can run the bot in a Telegram forum/supergroup with topic isolation:
- each topic gets its own memory/session scope
/newsessionand/memoryoperate on the current topic scope
Safe setup:
- Set
TELEGRAM_PRIVATE_ONLY=false - Set
ALLOWED_TELEGRAM_USER_IDSto your user id(s) - Set
ALLOWED_TELEGRAM_CHAT_IDSto only your allowed group id(s) - Set
TELEGRAM_GROUP_REQUIRE_MENTION=trueto make group handling predictable (@bot ...or reply-to-bot only)
This keeps one bot, but isolates context by topic.
Use the helper script:
./scripts/create-telegram-topic.sh "Facebook Ads"Or via npm:
npm run tg:topic -- "Facebook Ads"Notes:
- reads
.envautomatically - auto-selects the first
-100...id inALLOWED_TELEGRAM_CHAT_IDSunless you pass achat_id - verifies the chat is forum-enabled before creating the topic
Use Telegram command:
/autostart onto enable boot auto-start (launchd)/autostart offto disable boot auto-start/autostart statusto check current state
When enabled, the bot is installed as a user LaunchAgent and will come back after Mac restart.
Multi-agent is enabled for this bot runtime:
- app-server is started with
--enable multi_agent - per-thread config includes
features.multi_agent=true - developer instructions encourage silent internal delegation for complex tasks
- hidden complexity threshold (
MEMORY_MULTI_AGENT_COMPLEXITY_THRESHOLD) controls strategy:- below threshold: prefer single-agent
- above threshold: strongly push multi-agent delegation
npm testIncluded tests:
- remember timezone
- recall decision from two weeks ago
- avoid irrelevant old recall
- contradiction detection in heartbeat
src/index.jssrc/telegram.jssrc/skills.jssrc/memory.jssrc/db.jssrc/codex-client.js.env.example