Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing captions to WhatsApp audio messages throws an exception #348

Open
ash-jc-allen opened this issue Dec 16, 2022 · 0 comments
Open

Comments

@ash-jc-allen
Copy link
Contributor

Expected Behavior

I don't think you should be able to pass a caption for an audio message in WhatsApp. From looking at the docs, I get the impression that this is also the case (https://developer.vonage.com/messages/code-snippets/whatsapp/send-audio).

However, I'm new to tinkering with this API. So I apologise if I'm wrong! 😄

Current Behavior

It appears that if you pass a caption parameter to the Vonage\Messages\MessageObjects\AudioObject object, it will cause an API validation error because the caption field is unexpected.

Possible Solution

I'm probably not the best person to suggest a change for this. But my initial guess is that the AudioObject's toArray method should just ignore the caption field and not include it in the returned array. I think this could avoid a breaking change. But I guess this might confuse devs though if they're passing the caption field and not seeing it anywhere in the received WhatsApp message?

But, I think the long-term fix might be to completely remove all mentions of the caption field in the AudioObject.

Steps to Reproduce (for bugs)

I've been using this code here to reproduce the issue:

$whatsAppMessage = new WhatsAppAudio(
    to: 'NUMBER_GOES_HERE',
    from: 'NUMBER_GOES_HERE',
    audioObject: new AudioObject(
        url: 'AUDIO_URL_HERE',
        caption: 'CAPTION_HERE', // This line causes the error!
    ),
);

app(Client::class)
    ->messages()
    ->send($whatsAppMessage);

Context

I'm not currently using this in a real-world application. I was just writing an article about how to send WhatsApp messages from your Laravel app using Vonage.

Your Environment

  • Environment name and version (e.g. PHP 7.2 on nginx 1.19.1): PHP 8.1
  • Operating System and version: MacOS Ventura

Using the following Vonage packages in my Laravel app:

  • vonage/client - 3.0.0
  • vonage/client-core - 3.1.5
  • vonage/nexmo-bridge - 0.1.1
  • vonage/vonage-laravel - 1.0.0

I hope I've given enough info, but if you need anything else, feel free to give me a shout and I'll try to get back to you 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants