Skip to content

Examples

Explore practical examples of what you can build with Signal.Bot.

Basic Examples

Echo Bot

The simplest bot - echoes back everything you send it.

View Echo Bot Example →

Command Bot

A bot that responds to commands like /help, /time, /weather.

View Command Bot Example →

Quick Snippets

Send a Message

csharp
var client = new SignalBotClient(builder => builder
    .WithBaseUrl("http://localhost:8080")
    .WithNumber("+1234567890"));

await client.SendMessageAsync(builder =>
    builder
        .WithMessage("Hello!")
        .WithRecipient("+0987654321"));

Receive Messages

csharp

var disposable = await client.ReceiveAsync(
    updateHandler: (client, message, ct) =>
    {
        Console.WriteLine($"Received: {message.Envelope?.DataMessage?.Message}");
    },
    errorHandler: (client, ex, ct) => { Console.WriteLine($"Error: {ex.Exception?.Message ?? ""}"); },
    cancellationToken: cancellationToken);

Create a Group

csharp

var group = await client.CreateGroupAsync(builder =>
{
    builder
        .WithAddMemberPermission(GroupPermission.OnlyAdmins)
        .WithEditGroupPermission(GroupPermission.OnlyAdmins)
        .WithSendMessagesPermission(GroupPermission.OnlyAdmins)
        .WithMembers(["+1111111111", "+2222222222"])
        .WithName("My Group");
}, cancellationToken);

Send Attachment

csharp

await client.SendMessageAsync(builder =>
        builder
            .WithMessage("Check this out!")
            .WithRecipient("+0987654321")
            .WithAttachmentFromFile("/path/to/file.jpg", includeFilename: true),
    cancellationToken);

Running the Examples

All examples are available in the GitHub repository.

To run an example:

  1. Clone the repository
  2. Navigate to the example directory
  3. Update the configuration with your Signal number
  4. Run with dotnet run
bash
git clone https://github.com/st0o0/Signal.Bot.git
cd Signal.Bot/examples/echo-bot
dotnet run

Contributing Examples

Have a cool bot you've built with Signal.Bot? We'd love to feature it!

  1. Fork the repository
  2. Add your example to the examples/ directory
  3. Include a README with setup instructions
  4. Submit a pull request

Need Help?

If you're stuck on any example or have questions: