F
Filament16mo ago
EmmieB

Work with external API

How can I call a function that is from an external API that sends text to a phone number after a user has been created in a filament resources.
8 Replies
Patrick Boivin
Patrick Boivin16mo ago
You can look into Twilio for sending SMS, I've used it on a few projects: https://www.twilio.com/
Twilio
Communication APIs for SMS, Voice, Video & Authentication | Twilio
Connect with customers on their preferred channels—anywhere in the world. Quickly integrate powerful communication APIs to start building solutions for SMS and WhatsApp messaging, voice, video, and email.
EmmieB
EmmieBOP16mo ago
Alright good. Now how do I get the field value in my after create hook?
Diogo Pinto
Diogo Pinto16mo ago
You can create a new notification using Twilio. Then you can edit your CreateUser.php page and add something like:
protected function afterCreate(): void
{
$this->record->notify(new WelcomeEmail(Filament::getCurrentPanel()->getId()));
}
protected function afterCreate(): void
{
$this->record->notify(new WelcomeEmail(Filament::getCurrentPanel()->getId()));
}
The Welcome Email notification is something like:
public function __construct(private $panelId)
{
}
public function __construct(private $panelId)
{
}
and if you want to send a link to reset your password:
url(route("filament.{$this->panelId}.auth.password-reset.request")
url(route("filament.{$this->panelId}.auth.password-reset.request")
Patrick Boivin
Patrick Boivin16mo ago
$this->data['my_field_name']
EmmieB
EmmieBOP16mo ago
Data seems to be undefined . I'm using the aftercreate() function inside my StaffResource class which extends a Resource. It this the right place to use it?
No description
LeandroFerreira
LeandroFerreira16mo ago
CreateStaff.php afterCreate you can also use $this->record
EmmieB
EmmieBOP16mo ago
Fixed. Thanks
Want results from more Discord servers?
Add your server