Skip to content

feat: add AfricasTalking SMS adapter#17

Open
deepshekhardas wants to merge 6 commits into
mainfrom
feat/africastalking-adapter
Open

feat: add AfricasTalking SMS adapter#17
deepshekhardas wants to merge 6 commits into
mainfrom
feat/africastalking-adapter

Conversation

@deepshekhardas
Copy link
Copy Markdown
Owner

@deepshekhardas deepshekhardas commented May 14, 2026

Summary

Adds a new SMS adapter for AfricasTalking API.

Changes

  • New Adapter: Utopia\Messaging\Adapter\SMS\AfricasTalking
  • Supports sending SMS messages with optional sender ID
  • Handles up to 100 messages per request
  • Proper error handling with API error message extraction

Usage

use Utopia\Messaging\Adapter\SMS\AfricasTalking;
use Utopia\Messaging\Messages\SMS;

$sender = new AfricasTalking('username', 'api_key');

$message = new SMS(
    to: ['+254700000000'],
    content: 'Hello World',
    from: 'MY_SENDER_ID' // optional
);

$response = $sender->send($message);

Test Plan

  • Integration tests with environment-gated credentials
  • Tests both with and without custom sender ID

Summary by cubic

Adds an AfricasTalking SMS adapter and a new Messenger failover utility, plus new SMS adapters for Alibaba Cloud and Vonage. Also improves Mailgun and Msg91 handling for better compatibility and error reporting.

  • New Features

    • AfricasTalking SMS adapter: optional sender, up to 100 recipients per request, clear error extraction.
    • Alibaba Cloud SMS adapter: signed GET requests with query-string signature.
    • Vonage adapters: new VonageMessages (v1 API) and VonageLegacy (classic REST).
    • Messenger class: send via multiple adapters with automatic failover, type validation, and per-request limits.
  • Bug Fixes

    • Mailgun: support named recipients in "to", fix Reply-To header, and correct From formatting.
    • Msg91: extract API error messages instead of generic errors.
    • Vonage: guard against empty recipients and unify error handling.

Written for commit 075c715. Summary will update on new commits.

deepshekhardas added 6 commits March 16, 2026 17:56
Alibaba SMS signature validation requires query parameters, not body.
Moved signature params from request body to URL query string.

Identified by cubic (cubic.dev)
…ages API adapter

- Add Utopia\Messaging\Messenger class for automatic failover across multiple adapters
  - Accepts single Adapter or Adapter[]
  - Tries adapters sequentially on exception
  - Validates adapter compatibility (same type and message type)
  - Returns first successful response or throws aggregated exception

- Add VonageMessages adapter using Vonage Messages API (v1)
  - Uses Basic auth (Base64 encoded API Key:Secret)
  - JSON body with channel: SMS, message_type: text
  - Treats HTTP 202 as delivered

- Rename Vonage to VonageLegacy (legacy SMS API)
  - Keeps backwards compatibility for existing users

- Add tests: MessengerTest (14 cases), VonageMessagesTest, VonageLegacyTest
- Fix h:Reply-To header missing '=>' operator (was being ignored)
- Add support for named recipients in 'to' field (matching cc/bcc format)
- Fix from address format to RFC 5322 (space before <)
- New SMS adapter for AfricasTalking API
- Supports sending SMS messages with optional 'from' field
- Handles up to 100 messages per request
- Proper error handling for API responses
- Includes integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant