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

Anonymous/On Demand: [HTTP 400] Unable to create record: A 'To' phone number is required. #132

Open
alexc-wormhole opened this issue Feb 10, 2022 · 2 comments

Comments

@alexc-wormhole
Copy link

Laravel 8 using "laravel-notification-channels/twilio": "^3.1",

.env file:

TWILIO_USERNAME=
TWILIO_PASSWORD=
TWILIO_AUTH_TOKEN=[redacted_but_valid]
TWILIO_ACCOUNT_SID=[redacted_but_valid]
TWILIO_FROM=[redacted_but_valid]
TWILIO_ALPHA_SENDER=
#TWILIO_SMS_SERVICE_SID=[redacted_but_valid]
TWILIO_DEBUG_TO=
TWILIO_PHONE_SID=[redacted_but_valid]

Notification class:

    public function via ($notifiable)
    {
        return [TwilioChannel::class];
    }

    public function toTwilio ($notifiable)
    {
        return (new TwilioSmsMessage())
            ->content("test message");
    }

Called using:

Notification::route ('twilio', $phone)->notify (new GuestCodeWasGenerated ($this->code, $this->web_url));

Trace:

Twilio\Exceptions\RestException: [HTTP 400] Unable to create record: A 'To' phone number is required. in /var/www/html/vendor/twilio/sdk/src/Twilio/Version.php:88
Stack trace:
#0 /var/www/html/vendor/twilio/sdk/src/Twilio/Version.php(223): Twilio\Version->exception()
#1 /var/www/html/vendor/twilio/sdk/src/Twilio/Rest/Api/V2010/Account/MessageList.php(69): Twilio\Version->create()
#2 /var/www/html/vendor/laravel-notification-channels/twilio/src/Twilio.php(103): Twilio\Rest\Api\V2010\Account\MessageList->create()
#3 /var/www/html/vendor/laravel-notification-channels/twilio/src/Twilio.php(43): NotificationChannels\Twilio\Twilio->sendSmsMessage()
#4 /var/www/html/vendor/laravel-notification-channels/twilio/src/TwilioChannel.php(59): NotificationChannels\Twilio\Twilio->sendMessage()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): NotificationChannels\Twilio\TwilioChannel->send()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\Notifications\NotificationSender->sendToNotifiable()
@alexc-wormhole alexc-wormhole changed the title Anaonymous/On Demand: [HTTP 400] Unable to create record: A 'To' phone number is required. Anonymous/On Demand: [HTTP 400] Unable to create record: A 'To' phone number is required. Feb 10, 2022
@broadstreetboy
Copy link

broadstreetboy commented Feb 12, 2022

Set TWILIO_DEBUG_TO= to: TWILIO_DEBUG_TO=null and you'll be good to go.

It's getting caught up here in the sendSmsMessage() method:

        $debugTo = $this->config->getDebugTo();

        if ($debugTo !== null) {
            $to = $debugTo;
        }

@sawirricardo
Copy link

is this only in debugging? What about in production? it seems we need to set it to null in production

Set TWILIO_DEBUG_TO= to: TWILIO_DEBUG_TO=null and you'll be good to go.

It's getting caught up here in the sendSmsMessage() method:

        $debugTo = $this->config->getDebugTo();

        if ($debugTo !== null) {
            $to = $debugTo;
        }

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

No branches or pull requests

3 participants