For the complete documentation index, see llms.txt. This page is also available as Markdown.

Examples

Vector SDK Examples & Application

Runnable, self-contained example bots are bundled directly in the SDK crate under examples/, each one demonstrating a single concept. Unlike the old standalone example repository, these live alongside the SDK itself, so they are always kept in sync with the current API.

Every example requires a VECTOR_NSEC environment variable (the bot's key). A few require additional environment variables noted below.

Projects Overview

echo_bot

The minimal hello-world example. Replies to every message it receives.

  • Responds to direct messages and community messages alike

  • Demonstrates the basic on_message handler

slash_command_bot

A /command router demonstrating structured command handling.

  • Supports /ping, /echo, /roll, and /help

  • Demonstrates parsing message text into discrete commands

ai_bot

An LLM-backed chatbot wired to any OpenAI-compatible API endpoint.

  • Shows a typing indicator while generating a response

  • Maintains threaded replies and per-chat conversation history

  • Requires an OPENAI_API_KEY environment variable

moderation_bot

A community moderation bot demonstrating membership events and auto-moderation.

  • Welcomes new members when they join a community

  • Auto-bans members based on a configurable word filter

  • Demonstrates BotEvent::MemberJoin and the Member moderation API

whitelist_bot

A private bot that only joins communities run by trusted accounts.

  • Demonstrates the .whitelist([...]) invite policy

  • Rejects invites from any account not explicitly trusted

file_bot

A minimal example for sending files.

  • Sends a single file, then exits

  • Demonstrates Channel::send_file

save_files_bot

A minimal example for receiving files.

  • Saves every file it receives to disk

  • Demonstrates VectorBot::download_attachment / save_attachment

Usage

Each example can be run directly from the SDK crate. From the root of the repository:

For examples that require additional environment variables, such as ai_bot:

For a release build:

Contributing

Contributions are welcome. Please feel free to submit pull requests or open issues for any feature requests or bug reports.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Last updated