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
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
EmmieBOP2y ago
Alright good. Now how do I get the field value in my after create hook?
Diogo Pinto
Diogo Pinto2y 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
$this->data['my_field_name']
EmmieB
EmmieBOP2y 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
CreateStaff.php afterCreate you can also use $this->record
EmmieB
EmmieBOP2y ago
Fixed. Thanks

Did you find this page helpful?