Skip to content

warden-stack/Warden.Integrations.Twilio

Repository files navigation

Warden Twilio Integration

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

Branch Build status
master master branch build status
develop develop branch build status

TwilioIntegration can be used for sending the SMS using the Twilio. The required parameters are Account SID with Auth token for the account authentication and the default sender phone number e.g. +1111222333.

Installation:

Available as a NuGet package.

Install-Package Warden.Integrations.Twilio

Configuration:

  • WithDefaultMessage() - default body of the SMS.
  • WithDefaultReceivers() - default receiver(s) number(s).
  • WithTwilioServiceProvider() - provide a custom ITwilioService which is responsible for the sending SMS.

TwilioIntegration can be configured by using the TwilioIntegrationConfiguration class or via the lambda expression passed to a specialized constructor.

Initialization:

In order to register and resolve TwilioIntegration make use of the available extension methods while configuring the Warden:

var wardenConfiguration = WardenConfiguration
    .Create()
    .IntegrateWithTwilio("accountSid", "authToken", "+1111222333", cfg =>
    {
        cfg.WithDefaultMessage("Monitoring status")
           .WithDefaultReceivers("+1123456789");
    })
    .SetGlobalWatcherHooks((hooks, integrations) =>
    {
        hooks.OnStart(check => GlobalHookOnStart(check))
             .OnFailure(result => integrations.Twilio().SendSmsAsync("Monitoring errors have occured."))
    })
    //Configure watchers, hooks etc..

Custom interfaces:

public interface ITwilioService
{
    SendSmsAsync(string sender, string receiver, string message)
}

ITwilioService is responsible for sending the SMS. It can be configured via the WithTwilioServiceProvider() method. By default, it is based on the Twilio library.

Releases

No releases published

Packages

No packages published