Skip to content

Providers

Providers are pluggable components in Comby that handle external communication and integrations. They allow you to decouple the application logic from specific delivery mechanisms, making it easy to switch between different services without changing your core business logic.

Comby currently supports two types of providers:

Why Use Providers?

Providers offer several benefits:

  1. Decoupling: Separate business logic from delivery mechanisms
  2. Flexibility: Easily switch between different service providers
  3. Testing: Use NoOp providers during development and testing
  4. Customization: Implement custom providers for specific requirements
  5. Templates: Override default message templates per action

Common Features

All providers share common design patterns:

Interface-Based Design

Each provider type implements a specific interface, ensuring consistent behavior across different implementations.

Template Support

Providers support customizable templates with placeholder replacement:

go
provider.WithTemplate(
    "auth-account-login-opaque",
    "Login Code for {appName}",
    "Your verification code is: {code}\n\nValid for {expiresIn} minutes.",
)

Placeholders use the format {key} and are replaced with values from metadata.

Method Chaining

Most configuration methods return the provider instance, allowing for clean method chaining:

go
provider := NewSendgridEmailProvider(apiKey, sender, name).
    WithTemplate("action1", "Subject 1", "Body 1").
    WithTemplate("action2", "Subject 2", "Body 2")

Provider Types

Each provider category defines supported types:

MFA Provider TypesEmail Provider Types
emailsmtp
smssendgrid
totpses
webauthnmailgun
pushcustom
customnoop
noop

NoOp Providers

Each provider type includes a noop (no-operation) variant for development and testing. NoOp providers implement the interface but don't perform actual operations, making them ideal for:

  • Local development without external service dependencies
  • Testing without sending real messages
  • CI/CD pipelines where external communication is disabled

Next Steps