Logo

External APIs

SendInBlue (SMS & E-Mail)

Our platform uses SendinBlue for sending SMS and email notifications. We've integrated SendinBlue using the sendinblue/api-v3-sdk package and implemented custom classes for our use case. This section will cover the SendinBlueClient and SendinBlueService classes and their methods for handling different communication tasks.

SendinBlueClient Class

The SendinBlueClient class is located at App\Clients\SendinBlue. It includes methods to send SMS messages, register users with SendinBlue, create or update user entries, track SendinBlue events, and send transactional emails.

sendSms Method

This method sends an SMS message to a user using SendinBlue's Transactional SMS API. If the application environment is not set to production, the SMS content will be sent as an email instead.

public function sendSms(User $user, string $phoneNumber, string $message): ?SendSms;

identify Method

This method registers a user with SendinBlue by creating or updating their entry with the appropriate attributes.

public function identify(User $user);

createUpdate Method

This method creates or updates a user entry in SendinBlue.

public function createUpdate(string $email, array $attributes);

trackEvent Method

This method tracks SendinBlue events for a specific user.

public function trackEvent(string $email, string $event, array $properties, array $eventData = []);

sendTransactionalEmail Method

This method sends a transactional email using a SendinBlue email template.

public function sendTransactionalEmail(User $user, int $templateId, array $params = []);

SendinBlueService Class

The SendinBlueService class is located at App\Services\SendinBlueService. It handles the configuration and initialization of the SendinBlue API services.

getSmsService Method

This method initializes and returns an instance of the TransactionalSMSApi class.

public function getSmsService(): TransactionalSMSApi;

Getters

The following getter methods return various API configurations:

  • getApiKey()
  • getApiUrl()
  • getEventClientKey()
  • getEventApiUrl()

Working with SendinBlue Integration

Developers working on this integration should have a good understanding of the SendinBlue API, the sendinblue/api-v3-sdk package, and the custom classes created for this platform.

Previous
Vimeo (video player)