> For the complete documentation index, see [llms.txt](https://vector-privacy.gitbook.io/vector-privacy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/examples.md).

# Examples

## Vector SDK Examples

This repository contains various examples demonstrating how to use the [Vector SDK](https://github.com/VectorPrivacy/Vector-SDK). Each subfolder represents a distinct project with its own objectives and contributions to the overall repository. The projects are implemented in Rust and showcase different functionalities of the Vector SDK.

### Projects Overview

#### [HelloWorld](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/HelloWorld)

A simple "Hello World" example demonstrating basic setup and usage of the Vector SDK.

* Responds to private direct messages with "Hello World"
* **Files**: `Cargo.toml`, `src/main.rs`

#### [ImageResponse](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/ImageResponse)

Demonstrates how to send image responses using the Vector SDK.

* Responds to private messages with cat images from an external API
* **Files**: `Cargo.toml`, `src/main.rs`

#### [SendReactions](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/SendReactions)

Demonstrates sending reactions to messages using the Vector SDK.

* Responds to private messages with checkmark reactions
* **Files**: `Cargo.toml`, `src/main.rs`

#### [SendTypingMessage](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/SendTypingMessage)

Shows how to send typing message indicators using the Vector SDK.

* Sends typing indicators before responding with "Hello World"
* **Files**: `Cargo.toml`, `src/main.rs`

#### [Multi-command](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/Multi-command)

Combines multiple Vector SDK features into a single bot.

* Handles private messages and supports commands: `/rand`, `/help`, `/cat`, `/pivx`
* Demonstrates reactions, typing indicators, images, and API integration
* **Files**: `Cargo.toml`, `src/main.rs`

#### [Group/JoinAndSayHello](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/Group/JoinAndSayHello)

Demonstrates joining and participating in MLS (Messaging Layer Security) group conversations.

* Handles private direct messages and group messages
* Automatically responds with "Hello World" to private messages and group messages
* **Files**: `main.rs`

#### [Group/JoinAndMultiCommand](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/Group/JoinAndMultiCommand)

Advanced MLS group bot with multiple command support.

* Joins and listens to MLS group conversations
* Supports commands: `/help`, `/cat`
* Demonstrates reactions, typing indicators, and images in group chats
* **Files**: `Cargo.toml`, `src/main.rs`, `Vector-SDK/` (local SDK version)

#### [ScheduledMessages](https://github.com/Luke-Larsen/Vector-SDK-Example/blob/main/ScheduledMessages)

Demonstrates time-based message scheduling and background task management.

* Schedule one-time messages to be sent at specific times
* Schedule daily or weekly recurring messages
* List and cancel scheduled messages
* Demonstrates background task processing with Tokio
* **Files**: `Cargo.toml`, `src/main.rs`
* **Commands**: `/schedule`, `/list`, `/cancel`, `/help`

#### [PersistenceBot](#persistencebot)

Demonstrates state management and data persistence between bot restarts.

* Persists conversation history using SQLite database
* Stores and retrieves user preferences
* Tracks bot statistics
* Demonstrates database schema management and migrations
* **Files**: `Cargo.toml`, `src/main.rs`
* **Commands**: `/save`, `/load`, `/history`, `/stats`, `/help`

### Usage

Each project can be built and run independently. Navigate to the project directory and run:

```sh
cd <project-directory>
cargo run
```

For release builds:

```sh
cargo build --release
cargo run --release
```

### 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](https://github.com/VectorPrivacy/Vector-SDK/blob/mls-groups/LICENSE) file for details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
