Hi everyone!
I wanted to share something I recently figured out â I was facing an issue in Bubble.io where I needed to send emails to specific users or all users at once from a list. It seemed tricky at first, but I managed to solve it step by step, and I thought it might help others too!
Hereâs my approach:
Step 1: User Interface (Frontend)
- Add a Repeating Group (type: User, source: Search for Users).
- Inside each cell, add:
- A checkbox (to select the user).
- Any user details you want (name, email, etc.).
Step 2: Add âSelect Allâ and Track Selected Users
- Outside the repeating group, add a âSelect Allâ checkbox.
- Create a custom state (on the page or a group):
- Name:
SelectedUsers
- Type:
User
- Set to list
- Workflow logic:
- When a checkbox is checked in a cell â Add that user to
SelectedUsers
. - When unchecked â Remove that user from
SelectedUsers
. - When âSelect Allâ is checked â Set
SelectedUsers = RepeatingGroupâs List of Users
. - When unchecked â Clear
SelectedUsers
.
Step 3: Enable Backend Workflows
- Go to Settings â API.
- Check
Enable Workflow API and Backend Workflows.
Step 4: Create a Backend API Workflow
- Go to Backend Workflows (in the editor left panel).
- Click â+ New API Workflowâ, name it
send_email_to_user
. - Add these parameters:
user
(type: User)
- Inside the workflow, add an action:
- Action: Send Email
- To:
user's email
- Subject:
subject
- Body:
body
- inside this from, add an action schedule api workflow(send_email_to_user)
minus the user until it goes to first item(user:minus item user:first item) and put condition also (user:count>0)
Step 5: Trigger the Workflow from the Page
On the âSend Emailâ button:
- Workflow â Add action â Schedule API Workflow on a List
- Set:
- API Workflow:
send_email_to_user
(Schedules the API workflow and emails selected users.)
Step 6: Show Confirmation & Reset
- After the workflow:
- Show a popup or alert: âEmails sent successfullyâ
Final Result
Now the system works exactly as expected:
- I can send an email to just one person, a few selected people, or everyone at once.
- Itâs all smooth, efficient, and works in the background thanks to the backend workflow.
Iâm glad I figured this out; I hope it helps you if youâre facing a similar issue.