Skip to content

feat: add AfricasTalking SMS adapter#132

Open
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:feat/africastalking-adapter
Open

feat: add AfricasTalking SMS adapter#132
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:feat/africastalking-adapter

Conversation

@deepshekhardas

Copy link
Copy Markdown
  • 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

- 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
@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a new AfricasTalking SMS adapter following the existing adapter pattern in the repository. However, the implementation contains several defects that prevent it from working against the live Africa's Talking API.

  • The API_URL constant points to a non-existent path (/sms/1/action); the correct endpoint is https://api.africastalking.com/version1/messaging.
  • E.164 phone numbers have their + prefix stripped before being sent, but the Africa's Talking API requires the + and will reject numbers without it.
  • The optional from field is always included in the POST body even when null, which can trigger an API validation error.
  • No Accept: application/json header is sent, so the API returns XML by default and the response array-key access for error messages silently fails.

Confidence Score: 2/5

Not safe to merge — the adapter will fail to deliver any SMS in its current state.

The core process() method has four independent defects, each sufficient to break every request: the API URL is incorrect and does not resolve to a real endpoint; the + prefix is stripped from recipients that Africa's Talking requires in E.164 format; the from field is sent as null when optional, risking validation rejections; and the missing JSON Accept header means responses arrive as XML, breaking all error-message extraction.

src/Utopia/Messaging/Adapter/SMS/AfricasTalking.php requires attention across the API URL constant, phone number mapping, request headers, and body construction.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/AfricasTalking.php New SMS adapter with four blocking defects: wrong API endpoint URL, unintended stripping of E.164 + prefix from recipients, null from always included in the request body, and missing Accept: application/json header causing XML responses.
tests/Messaging/Adapter/SMS/AfricasTalkingTest.php Integration tests correctly skip when credentials are absent; the json_decode issue on the response was noted in a previous thread and is the only remaining concern.

Reviews (2): Last reviewed commit: "fix: add parent constructor, type-safe e..." | Re-trigger Greptile

Comment thread src/Utopia/Messaging/Adapter/SMS/AfricasTalking.php
Comment on lines +59 to +61
if ($result['statusCode'] === 201) {
$response->incrementDeliveredTo();
$response->addResult($recipient);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Check recipient status

Africa's Talking returns per-recipient statuses in SMSMessageData.Recipients, including failures such as invalid numbers or insufficient balance, while the HTTP request itself can still succeed. This branch marks every 201 response as delivered without reading those recipient statuses, so callers can receive success and an incremented deliveredTo count for messages the provider rejected.

Artifacts

Repro: focused PHP harness mocking a 201 failed-recipient Africa's Talking response

  • Contains supporting evidence from the run (text/x-php; charset=utf-8).

Repro: harness execution output showing HTTP 201 Created and adapter success/deliveredTo behavior

  • Keeps the command output available without making the summary code-heavy.

View artifacts

T-Rex Ran code and verified through T-Rex

Comment thread tests/Messaging/Adapter/SMS/AfricasTalkingTest.php Outdated
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