Creating your first Flow

Flows are a combination of Based ‘scripts’, and are the instructions for your AI workers. With Flows, you can create fully customized AI workers in minutes.

You can create flows by either choosing from one of our dozens of templates, or by creating a worker from scratch.

Flows are composed of two types of scripts: actions and triggers.

Actions are scripts you can manually execute via the database, or that can be executed by workers during phone and zoom calls.

Triggers are scripts triggered by an event, such as an email being recieved, phone call ending, or item being found in a document.

A worker typically consists of multiple actions or triggers, and you can include as many of these as needed within a single worker.

Ready? Let’s dive in and create our first worker! We will create a simple, automatic resume reviewer for handling large amounts of inbound resumes.

Step 1: Configure Your Database & Upload Documents

To start, we’ll set up three columns in our database: First Name, Last Name, Summary, Mentions Python, and Email Address. For each column, we’ll also include a description to guide our LLM in extracting the right information.

By giving a brief description when creating columns, our document processor will accurately determine which data to extract from your uploaded documents and place into the designated columns. With our database now set up, we can upload resumes, and the document processor will extract the specified columns from the documents.

Step 2: Create an Action

Now that we have the necessary data from our resumes, we can create our first flow!

The first action will email candidates who mention Python and ask them for a phone screen interview ( which we can also conduct using Brainbase, but we will save that for a later tutorial).

Navigate to flows and create a new flow. We will call this one “Email Candidates for Follow Up”

def wf(obj):
    if obj['mentions_python'] == 'true':
        gmail.send_email(receiver=obj['email_address'], 
                         body_text=f"""Hi {obj['first_name']}, 
                         \n congartulations! We'd like to invite you to our next round of interviews! Please let me know when you are available this week. """, 
                         subject="Update on Brainbase Application")

For actions, obj is the row we are executing the action on. It is essentially a JSON, and you can access any column values by writing obj[{column_name}]

You can write flows using all of the same tools and syntax as Python, including for loops, if statements, list comprehension etc.

Now that we have created our first action, lets go ahead and execute it! We can select every row in our database and use this flow to determine who to send an email to.

And in about 20 seconds, we have sent out emails to all of our candidates who mentioned Python in their resume.

Here is the email that koenmatt@berkeley.edu recieved:

Now that they have received our email, we should be ready to respond. We can create a trigger that will respond to the candidates response.

@trigger gmail.new_email(fromAddress="koenmatt@berkeley.edu")
def wf(obj):
    response = obj.ask("create an email response to the body_plain from this email")
    subject = obj.ask("create an email subject line for an email responding to body_plain from this email")
    gmail.send_email(receiver="koenmatt@berkeley.edu", subject=subject, body_text=response)

For triggers, obj is the object that gets returned by this specific trigger (which are in the docs too). In this case, it is a JSON object returned by new_email. Every object in Based also has a .ask method, which allows you to ask our LLM about this object. In this case, we want to ask the LLM to draft a response to the candidates email.

And just like that, we’ve created our first worker in under 5 minutes! This worker can analyze resumes, send emails to selected candidates, and even respond to their replies.

With over 100+ integrations and counting, state of the art LLM’s, and the fastest, most realistic voice server available, we only scratched the surface of what Brainbase is capabale of.

Brainbase provides tailored solutions created by our team, ready-to-use templates, or the option to build your own just like this. Everything is fully customizable, scalable, and secure.

Ready to get started? Join our waitlist.