Skip to content

feat: add Telnyx SMS adapter (#7811)#108

Open
deepshekhardas wants to merge 1 commit intoutopia-php:mainfrom
deepshekhardas:feat/7811-telnyx-adapter
Open

feat: add Telnyx SMS adapter (#7811)#108
deepshekhardas wants to merge 1 commit intoutopia-php:mainfrom
deepshekhardas:feat/7811-telnyx-adapter

Conversation

@deepshekhardas
Copy link

@deepshekhardas deepshekhardas commented Mar 16, 2026

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Bug Fixes

    • Refactored SMS delivery mechanism to process individual requests per recipient, enabling accurate delivery tracking and status monitoring for each message.
    • Improved failure reporting with per-recipient error details for better diagnostics.
  • Tests

    • Activated SMS adapter test suite to ensure proper functionality and reliability of SMS sending operations.

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Walkthrough

The Telnyx SMS adapter's constructor parameter $from was changed from nullable to required non-nullable. The process() method was refactored to send individual API requests for each recipient instead of a single batch request. Request construction now uses string interpolation for headers and includes per-recipient values for from, to, and text fields. Delivery reporting and error handling were updated to track metrics per recipient. The corresponding test file was updated to enable the Telnyx sender, construct actual SMS objects using environment variables, and execute assertions instead of placeholder code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: add Telnyx SMS adapter' clearly and accurately summarizes the main change: adding a new SMS adapter for the Telnyx service provider.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Messaging/Adapter/SMS/TelnyxTest.php`:
- Around line 16-22: The test fails because Telnyx is instantiated with too few
arguments and doesn't guard missing env vars; update the test in TelnyxTest to
first read and validate getenv('TELNYX_API_KEY'), getenv('TELNYX_TO') and
getenv('TELNYX_FROM') and call markTestSkipped (or return) if any are empty,
then construct the Telnyx sender passing the required from argument (e.g.,
include the from value when calling new Telnyx(...)) and create the SMS using
the validated env values before calling send.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea64e157-ee53-4fa5-baaf-f297eaae6463

📥 Commits

Reviewing files that changed from the base of the PR and between fcb4c3c and e416217.

📒 Files selected for processing (2)
  • src/Utopia/Messaging/Adapter/SMS/Telnyx.php
  • tests/Messaging/Adapter/SMS/TelnyxTest.php

Comment on lines +16 to +22
$sender = new Telnyx(\getenv('TELNYX_API_KEY'));

// $message = new SMS(
// to: ['+18034041123'],
// content: 'Test Content',
// from: '+15005550006'
// );
$message = new SMS(
to: [\getenv('TELNYX_TO')],
content: 'Test Content',
from: \getenv('TELNYX_FROM')
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Pass the required Telnyx from argument and guard missing env vars.

This test currently instantiates Telnyx with too few arguments, which will fail before the send call runs. It also should skip cleanly when Telnyx env vars are not configured.

Proposed patch
 public function testSendSMS(): void
 {
-    $sender = new Telnyx(\getenv('TELNYX_API_KEY'));
+    $apiKey = \getenv('TELNYX_API_KEY') ?: null;
+    $from = \getenv('TELNYX_FROM') ?: null;
+    $to = \getenv('TELNYX_TO') ?: null;
+
+    if (!$apiKey || !$from || !$to) {
+        $this->markTestSkipped('TELNYX_API_KEY, TELNYX_FROM, and TELNYX_TO are required for this integration test.');
+    }
+
+    $sender = new Telnyx($apiKey, $from);
 
     $message = new SMS(
-        to: [\getenv('TELNYX_TO')],
+        to: [$to],
         content: 'Test Content',
-        from: \getenv('TELNYX_FROM')
+        from: $from
     );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$sender = new Telnyx(\getenv('TELNYX_API_KEY'));
// $message = new SMS(
// to: ['+18034041123'],
// content: 'Test Content',
// from: '+15005550006'
// );
$message = new SMS(
to: [\getenv('TELNYX_TO')],
content: 'Test Content',
from: \getenv('TELNYX_FROM')
);
$apiKey = \getenv('TELNYX_API_KEY') ?: null;
$from = \getenv('TELNYX_FROM') ?: null;
$to = \getenv('TELNYX_TO') ?: null;
if (!$apiKey || !$from || !$to) {
$this->markTestSkipped('TELNYX_API_KEY, TELNYX_FROM, and TELNYX_TO are required for this integration test.');
}
$sender = new Telnyx($apiKey, $from);
$message = new SMS(
to: [$to],
content: 'Test Content',
from: $from
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Messaging/Adapter/SMS/TelnyxTest.php` around lines 16 - 22, The test
fails because Telnyx is instantiated with too few arguments and doesn't guard
missing env vars; update the test in TelnyxTest to first read and validate
getenv('TELNYX_API_KEY'), getenv('TELNYX_TO') and getenv('TELNYX_FROM') and call
markTestSkipped (or return) if any are empty, then construct the Telnyx sender
passing the required from argument (e.g., include the from value when calling
new Telnyx(...)) and create the SMS using the validated env values before
calling send.

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