n8n flows
Invite Users to Client Portal
Invites one or more users to an account's client portal: creates the auth user, assigns the account role, and emails a welcome message telling them to sign in with a code.
Invites one or more users to the National Commerce client portal for a given account. It creates the Supabase auth user, assigns the account role, and emails a branded welcome message. It also handles the "already a member" case.
At a glance
- Status: Active
- Trigger: Webhook (
POST /webhook/0805be40-1cc9-4415-8355-80bc16122185), answered by a Respond-to-Webhook node. - Runs on: A call carrying one or more users and their accounts, from the portal's invite route (server side) or New Brand Onboarding. The portal reads this webhook's URL from
N8N_INVITE_WEBHOOK_URL, which is set on production only. - Talks to: Supabase (Auth Admin
generate_link,get_user_uuid_by_emailRPC, userRoles); Gmail.
How it works
- The webhook responds immediately, then
Prepare Users Arrayfeeds a counter loop over each user. Get User Via Emailcalls the Supabase RPCget_user_uuid_by_email, then branches on whether the user exists.- Existing users: check
userRolesfor the account and either return a 400 "already exists" or add a new account role. - New users:
Generate Invite Link For Usercalls Supabase Admingenerate_linkwith typeinvite. This is what creates the auth user. Then the welcome email is sent, and in parallelBuild Account Rolesmakes oneuserRolesrow per account forAdd New User Role To Brand1to insert. Send Invite Emailsends a branded HTML message via Gmail. It tells the user to go to portal.nationalcommerce.com/login, enter their email, and sign in with the 6-digit code they're sent. There is no password to set.
The invite link is no longer used
generate_link still returns a one-time link (with redirect_to pointing at
the old /update-password page, which no longer exists). The email does not
include it. The step is kept because it is what creates the user.
Notes
- Called by New Brand Onboarding.
callerPolicy: workflowsFromSameOwner.- Accounts: the body's
brand_idslist, orbrand_idalone for callers that send one account (New Brand Onboarding). - Type: new users are Client Users unless the call carries
role_idfor NC Internal User and thex-invite-secretheader matching the shared secret inBuild Account Roles. The portal sends it from theN8N_INVITE_SECRETenv var, so the public webhook URL alone can't create an NC Internal User. NC Super Admin is never accepted. - The existing-user branch still adds a Client User row for the one
brand_id. The portal only sends brand-new emails here; it gives existing users their accounts itself. - Shared
error-handlerset as the error workflow. Create Default User Preferences,Add User Preferences, andAssign User To Brandsit on the canvas but nothing connects into them, so they never run. New users get nouser_settingsrow from this flow, which is why every email starts off. See Notifications.- A new user who requests a sign-in code within a minute of the invite gets "Too many requests".
generate_linkmarks the address as just emailed, and each address can get one email per minute. - The Supabase service key is hardcoded in the HTTP Request nodes' headers rather than stored as an n8n credential.