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.
Command Bot
A bot that responds to commands like /help, /time, /weather.
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:
- Clone the repository
- Navigate to the example directory
- Update the configuration with your Signal number
- Run with
dotnet run
bash
git clone https://github.com/st0o0/Signal.Bot.git
cd Signal.Bot/examples/echo-bot
dotnet runContributing Examples
Have a cool bot you've built with Signal.Bot? We'd love to feature it!
- Fork the repository
- Add your example to the
examples/directory - Include a README with setup instructions
- Submit a pull request
Need Help?
If you're stuck on any example or have questions:
- Open an issue on GitHub
- Review the guides
