Twilio Laravel Send Whatsapp Message not in same channel

Published

I have try to create MEssage from php(laravel) using twilio,
when i send messsage and system reply it well,

but i have some problem when i want directly send message directly from system,I call my service from POSTMAN but it will always show error notif like this

TwilioExceptionsRestException: [HTTP 400] Unable to create record: From(whatsapp:+14155238886) and To(+6281210357927) addresses should be of the same channel. in file D:WelldyNewLARAVUEpwivendortwiliosdksrcTwilioVersion.php on line 88

is it because I call api from POSTMAN? so how I can send message with calling my api?

public function sendTest(Request $request){
    $from = $request->input('From');
    $body = $request->input('Body');
    $this->sendWhatsAppMessage($body,$from);
    return;    
}

public function sendWhatsAppMessage(string $message, string $recipient)
{
    $twilio_whatsapp_number = getenv('TWILIO_WHATSAPP_NUMBER');
    $account_sid = getenv("TWILIO_SID");
    $auth_token = getenv("TWILIO_AUTH_TOKEN");

    $client = new Client($account_sid, $auth_token);
    return $client->messages->create($recipient, array('from' => "whatsapp:$twilio_whatsapp_number", 'body' => $message));
}

Source: Laravel

Published
Categorised as laravel, twilio, twilio-api, twilio-php Tagged , , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq