Text Message
Description
Message providers in FlexBase expose a unified interface (IFlexTextMessageProvider) for sending SMS and notifications across providers like Twilio, Firebase, and AWS SNS.
Your application code should depend on IFlexTextMessageProvider.
Important concepts
IFlexTextMessageProvideris the contract: send viaSendSmsAsync(...),SendPushAsync(...), orSendAsync(...).Provider bridge: generated infrastructure commonly registers
IFlexTextMessageProviderBridge(which also implementsIFlexTextMessageProvider) so behavior can be overridden safely.Channel support is provider-specific: use
SupportedChannels/SupportsChannel(...)to validate capability.
Configuration in DI
Only register the provider—Flex auto-wires generated PostBus handlers/plugins that consume the interface.
public static class OtherApplicationServicesConfig
{
public static IServiceCollection AddOtherApplicationServices(
this IServiceCollection services,
IConfiguration configuration)
{
// Pick ONE (or register multiple with different compositions).
services.AddFlexConsoleMessageProvider(configuration);
// services.AddFlexTwilioMessageProvider(configuration);
// services.AddFlexFirebaseMessageProvider(configuration);
// services.AddFlexAwsSnsMessageProvider(configuration);
return services;
}
}appsettings.json
Message provider configuration is read from FlexBase:Providers:Message:<Provider>.
Examples (template-based)
This mirrors the generated PostBus handler template shape. You do not register the handler manually.
Provider considerations
Validate channel support via
SupportsChannel(...)before sending.Keep secrets (Twilio/AuthToken, AWS keys, Firebase credentials) out of source control. ["action"] = "verify", ["userId"] = 12345 }, Metadata = new Dictionary<string, string> // Tracking metadata { ["campaign"] = "signup", ["source"] = "web" } };
var result = await _messageProvider.SendAsync(message); }
Bulk Messaging
Slack/Teams Integration
Key Points to Consider
Best Practices
Validate Recipients - Use
ValidateRecipient()before sendingHandle Delivery Status - Check
IsSuccessand log failuresUse Console in Dev - Avoid sending real messages during development
Set Priorities - Use
Highpriority for time-sensitive messagesInclude Expiry - Set
ExpiresAtfor time-sensitive contentHandle Rate Limits - Implement retry logic for
RATE_LIMITEDerrorsMonitor Costs - Track
Costin results for paid providers
Validation
Error Handling
Testing Connection
Examples
Complete Notification Service
Multi-Channel Alert System
Testing
See Also
Email Providers - Email sending
FlexMessage Provider Reference - Detailed API documentation
Last updated