Bento

Laravel User Importer

We understand that the thought of switching from your current provider or beginning with a marketing system like Bento can be daunting, especially when it comes to importing users. That's why we designed this importer to streamline and automate the process, allowing you to quickly kick off and focus on real-world applications without the usual headaches.

Setup

Once you've set up the Laravel SDK, you're all set! Should you need to install it, simply refer to the provided installation guide to get started.

Running the first import

From your laravel install run the following artisan command. This will import all the users from your users table, and set a few helpful tags.

  • An imported_at time stamp field when the user was imported
  • An onboarding_complete tag, this ensures you have the ability to skip any new flows or onboarding drips for existing users.

Bento doesn't duplicate subscribers with the same email so it is safe to run as many times as you need to.

php artisan bento:import-users

Command Result

Successfully imported 2 users. Failed to import 0 users.

About Failed imports

Every email must pass a validation check in order to be imported. Subscribers that fail this check will fail to import. This helps keep your subscriber data pristine, ensuring the best delivery rate. If you find you have many failures on your first import, reach out to support in Discord for help.

What data is getting imported?

The default Laravel users table includes a unique email column and a name column. These are imported by default when using the command. If your use case requires no additional information, you're all set. However, if you've customized the table or expanded the user information you collect, we recommend passing the data to the user import class as detailed in the customization section.

keysample
email[email protected]
nameJohn Doe

We split the name column with the following simple rule: first name is the name key up to the first space, last name is from that space to the end of the name. While we realize this might not fit every possible name it covers the vast majority. You can format the data to suit your needs and pass it to the Action class should this not meet your use case.

A new user in your bento account will have the following data:

Fields:

keyvalue
last_nameDoe
first_nameJohn
imported_at2024-10-09T05:08:28.831461Z

Tags:

onboarding_complete

These are great starting values, just be aware for fields that you will want to make sure they match with any other data source. Customizations might need to be made to ensure everything matches.

Customization

The user_import class that powers the command allows you to customize and reuse it should you need to modify what data you want imported, or if you wanted to create your own scheduled job that runs to import users. This flexible Action class can also be integrated into various processes such as user creation or onboarding.

The action class, by default, will chunk the collection into API calls to Bento, ensuring no more than 500 records are processed at a time.

use Bentonow\BentoLaravel\Actions\UserImportAction;
use Bentonow\BentoLaravel\DataTransferObjects\ImportSubscribersData;

$data = collect([
  new ImportSubscribersData(
    email: "[email protected]",
    first_name: "Jane",
    last_name: "Doe",
    tags: ["onboarding", "imported", "mobile_app"],
    fields: ["imported_by" => 'laravel']
  )
]);

(new UserImportAction)->execute($data);

If you have any other questions, feel free to ask in the Bento Discord!

Was this page helpful?