[go: up one dir, main page]

Skip to content

Signal.BotA .NET Signal Messenger Bot Client

Build powerful Signal bots with the simplicity of Telegram.Bot

Signal.Bot

Quick Example

csharp
const string baseUrl = "http://localhost:8080";
// Your registered Signal number
const string botNumber = "+1234567890";

var client = new SignalBotClient(builder =>
{
    builder
        .WithBaseUrl(baseUrl)
        .WithNumber(botNumber);
});

using var cts = new CancellationTokenSource();

client.StartReceiving(async (botClient, message, ct) =>
    {
        Console.WriteLine($"Received from {message.Account}: {message.Envelope?.DataMessage?.Message}");

        // Echo the message back
        if (!string.IsNullOrEmpty(message.Envelope?.DataMessage?.Message))
        {
            await botClient.SendMessageAsync(
                builder => builder
                    .WithRecipient(message.Envelope!.SourceNumber!)
                    .WithMessage($"You said: {message.Envelope?.DataMessage.Message}")
                , cancellationToken: ct);
        }
    },
    async (botClient, error, ct) =>
    {
        Console.WriteLine($"Error: {error.Source}:{error.Exception?.Message}");
        await Task.CompletedTask;
    }, builder => builder.WithMaxMessages(1), cts.Token);

Why Signal.Bot?

Signal.Bot was born from a simple question: "Why is there a polished Telegram.Bot library for .NET, but nothing similar for Signal?"

If you've ever wanted to build a Signal bot in .NET but were put off by the lack of proper tooling, this library is for you. It wraps the signal-cli-rest-api with a clean, intuitive interface that feels familiar to anyone who's used Telegram.Bot.

Installation

bash
dotnet add package Signal.Bot
bash
Install-Package Signal.Bot
xml
<PackageReference Include="Signal.Bot" Version="1.0.0" />