Skip to content

feat: Add Vonage Messages Adapter (#8139)#7

Open
deepshekhardas wants to merge 1 commit into
mainfrom
feat/8139-vonage-messages-adapter
Open

feat: Add Vonage Messages Adapter (#8139)#7
deepshekhardas wants to merge 1 commit into
mainfrom
feat/8139-vonage-messages-adapter

Conversation

@deepshekhardas
Copy link
Copy Markdown
Owner

@deepshekhardas deepshekhardas commented Apr 11, 2026

This PR adds support for Vonage Messages API adapter.

Changes:

  • Implements Vonage Messages API integration
  • Supports multiple message types (SMS, WhatsApp, etc.)
  • Follows existing adapter patterns

Summary by cubic

Add a Vonage Messages adapter with SMS, WhatsApp, Viber, and MMS support. Uses a shared trait with JWT auth and follows the existing adapter pattern.

  • New Features

    • Added abstract channel adapters: WhatsApp, Viber, MMS.
    • Added channel implementations: SMS\VonageMessages, WhatsApp\Vonage, Viber\Vonage, MMS\Vonage.
    • Introduced VonageTrait to build payloads, sign JWTs (RS256), and POST to https://api.nexmo.com/v1/messages.
    • Sends one recipient per request and returns a normalized response (delivered on 2xx with message_uuid, otherwise includes error).
  • Migration

    • Construct adapters with Vonage Application ID and Private Key; optional from is supported.
    • No breaking changes to existing adapters.

Written for commit ba22934. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/Utopia/Messaging/Adapter/VonageTrait.php">

<violation number="1" location="src/Utopia/Messaging/Adapter/VonageTrait.php:30">
P2: Guard against empty recipient lists before reading `$message->getTo()[0]`; otherwise this path triggers undefined index warnings and builds invalid requests.</violation>
</file>

<file name="src/Utopia/Messaging/Adapter/SMS/VonageMessages.php">

<violation number="1" location="src/Utopia/Messaging/Adapter/SMS/VonageMessages.php:12">
P1: `VonageTrait` is referenced from the wrong namespace. This class needs to import or fully qualify `Utopia\Messaging\Adapter\VonageTrait`, otherwise it will fail to load.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


class VonageMessages extends SMSAdapter
{
use VonageTrait;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

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

P1: VonageTrait is referenced from the wrong namespace. This class needs to import or fully qualify Utopia\Messaging\Adapter\VonageTrait, otherwise it will fail to load.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Utopia/Messaging/Adapter/SMS/VonageMessages.php, line 12:

<comment>`VonageTrait` is referenced from the wrong namespace. This class needs to import or fully qualify `Utopia\Messaging\Adapter\VonageTrait`, otherwise it will fail to load.</comment>

<file context>
@@ -0,0 +1,34 @@
+
+class VonageMessages extends SMSAdapter
+{
+    use VonageTrait;
+
+    protected const NAME = 'VonageMessages';
</file context>
Suggested change
use VonageTrait;
use \Utopia\Messaging\Adapter\VonageTrait;
Fix with Cubic

{
$payload = [
'from' => $this->from ?? $message->getFrom(),
'to' => \ltrim($message->getTo()[0], '+'),
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

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

P2: Guard against empty recipient lists before reading $message->getTo()[0]; otherwise this path triggers undefined index warnings and builds invalid requests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Utopia/Messaging/Adapter/VonageTrait.php, line 30:

<comment>Guard against empty recipient lists before reading `$message->getTo()[0]`; otherwise this path triggers undefined index warnings and builds invalid requests.</comment>

<file context>
@@ -0,0 +1,72 @@
+    {
+        $payload = [
+            'from' => $this->from ?? $message->getFrom(),
+            'to' => \ltrim($message->getTo()[0], '+'),
+            'message_type' => 'text',
+            'text' => $message->getContent(),
</file context>
Fix with Cubic

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