Laravel Bento Quick Start
This tutorial sets up Bento in a Laravel app using the Bento-laravel-sdk. You'll configure Bento as your mail transport, send a transactional email, and sync new users to Bento with tags and fields.
Prepare your Laravel environment. This tutorial starts with a fresh install, but the SDK works the same in existing applications.
- Install Laravel:
- Install dependencies:
- Set up Bento:
Next, configure your app to work with Bento. You can find your Bento API keys and Site_UUID in the Bento account dashboard. Don't share them or commit them to source code.
If you want Bento to handle your transactional email, the SDK includes a transport for your convenience.
- Open your
.envfile and add these lines:
- Update your
config/mail.phpfile to use Bento as the mail transport:
mail.php configuration, but you can also set it in your .env file via the MAIL_MAILER key.Create a simple mailable that uses a view and sends it as a Bento transactional email.
- Create a new mailable:
- Edit
app/Mail/WelcomeMail.phpand make a few additions:
- Create a view for the email at
resources/views/emails/welcome.blade.php:
- Use the mailable. For example, edit
App\Http\Controllers\Auth\RegisteredUserController:
When a user registers, add them as a subscriber to Bento. That way you can capture their activity and use it to trigger email flows in Bento.
- Jump back into
RegisteredUserController:
Tags are great ways to segment users. In many email platforms they would be considered lists.
- Tag the new user based on their source (website):
Tags are great for segmentation, but sometimes you need to store user data to personalize emails. Fields are perfect for this.
- Record a user's favorite color:
With Bento's API, you can quickly build a complete subscriber profile for better targeting and personalization, often with a single API call.
ImportSubscribers method safely merges new fields into a user's data without triggering any flows or events from the data you send.Next Steps
Your Laravel app is now integrated with Bento. You can send email, sync new users as subscribers, tag them, and record custom data in fields for use in emails with liquid tags.
From here, explore more Bento features and tailor them to your needs. Contact us in Discord if you need help or have suggestions!
