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
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.
You can probably send the message from the
afterCreate()
hook:
https://filamentphp.com/docs/3.x/panels/resources/creating-records#lifecycle-hooksAlright good. Now how do I get the field value in my after create hook?
You can create a new notification using Twilio. Then you can edit your CreateUser.php page and add something like:
The Welcome Email notification is something like:
and if you want to send a link to reset your password:
$this->data['my_field_name']
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?
CreateStaff.php
afterCreate you can also use
$this->record
Fixed. Thanks