Detecting if a domain name exists inside a database using API connector or Backend workflows

Hello,

I am new to backend workflows and API connector so please help me out.

I am trying to create a simple workflow where a user puts in their email (let’s say joe@samsung.com) and a backend workflow simply takes that email as input and searches inside the database if a company belonging to that domain name exists.

So in the example I mentioned the user would enter joe@samsung.com, the platform would go and look for samsung.com (so first step is to actually extract the domain name, that’s fine) and then search and return yes/no if Samsung exists in the database. Then I’ll just display “yes” or “no” on the UI.

That said, I don’t know if I should use backend workflows only or API connector. When I use backend workflows, I couldn’t really manage to make it work. When I used API connector, it actually worked fine when I was initializing it (I would need to pass an example email to see if it worked, and it did) but I’m not knowing how to make the UI pass the value to the API call of the connector…

Its would be very simple, if the domain are public you can searchthem while being frontend, if the domains are private we need to build backend api call which take parameters like user email and then extract the domain and do a search in database for the usign the domain, and if it found it return doamin exist and if not it will return domain do not exist.

IF the doamin are public, you can do the search while beng in frontend, you need a entity in you database, which contian the doamina.

* **Now answering you

  • for backend api workflow to return data we need to call via API-Connect, and inside api connect we need to create parameter for exact name which we have within backend API workflwo and uncheck the private checkbox so we can dinamicly add value into it withing frontend workflwo.
    **
    *

if you need help buildign the logic ping me any time.

Hi @ahmadomfatfat
This can be done entirely on the frontend with a simple workflow.
Use Bubble’s text operators:

Input Email's value :extract with Regex ([^@]+$)

Or simpler:

Input Email's value :split by (@) :last item

This turns joe@samsung.comsamsung.com

Next, search database for matching company:

Do a search for Companies
Constraint: domain = Input Email’s value :split by (@) :last item
:count > 0

This returns yes (true) or no (false)

Here is the workflow to achieve this:

When Button “Check” is clicked:
Step 1: Set state on Group “Result”

  • Custom state: company_exists (type: yes/no)
  • Value: Do a search for Companies (domain = Input Email’s value :split by (@) :last item) :count > 0

On the text element, add these conditionals:

When Group Result’s company_exists is yes → Text = “Yes”
When Group Result’s company_exists is no → Text = “No”

1 Like