Check your config file on production and insure that you have your URL specified correctly. I am guessing that Twilio cannot access your audio file.
Sep 30, 2020
5
Level 37
Laravel make a call to a phone through Twilio
I am wondering if someone can help me here for a Twilio Call, here is the code:
$lead = Lead::findOrFail($request->id);
$notification = NotificationSetting::find($request->prc);
$response = new VoiceResponse();
$response->play(url('storage/'.$notification->voice_call), ['loop' => 10]);
$client = new Client(config('mtc.twilio.sid'), config('mtc.twilio.token'));
$call = $client->account->calls
->create('+1'.$lead->phone, // to
config('mtc.twilio.from'), //from
['twiml' => $response]
);
The problem is when I call the code through ngrok it works fine, but when I using through forge.laravel.com, it doesn't. It calls my phone but it tells me that there is an error. While when I use my local, it works just fine.
Any idea why?
Thank you,
Level 37
I got the problem, thank you for your support.
The problem was when I use the code:
$request->file_name->store('notifications', 'public');
Laravel is considering that the file is not mp3, instead it's mpga, so it uploaded it as mpga.
I used instead:
$file = $request->file_name;
$file->move(public_path('storage/notification)', $filename);
it worked perfectly.
Please or to participate in this conversation.