•••
 
Documentation   /   Building workflows   /   Building your first workflow
 
 

Building your first workflow

 

This walkthrough builds a small workflow, "Request an NDA", in both the visual editor and the code editor. It asks whether the NDA is one-way or mutual, creates the right document, and emails Legal.

1. Plan the process

Before opening the editor, write the steps down and mark where the process branches:

  1. Ask: one-way or mutual?
  2. If one-way, create the one-way NDA. If mutual, create the mutual NDA.
  3. Email Legal to say a new NDA has been created.

You'll need two templates, one for each NDA. See Building your first template.

2. Create the workflow

  1. Open the Toolkit and go to Workflows.
  2. Click New workflow, give it a name and description, and save.

The workflow opens in the visual editor.

3. Add the steps

In the visual editor, add actions from the action menu:

  1. Add a Multiple choice question titled "What kind of NDA?" with two answers, "One-way" and "Mutual".
  2. Add two Make document (automatically) actions, one for each NDA template.
  3. Add an Auto email to Legal.

4. Connect the steps

Connections decide what happens next. Connect from the question to each document action and choose Sometimes, setting the condition to the answer that leads there. Connect each document action to an email with Always.

Note

An item can only have one "next" item at a time. If two branches should end with the same step, each branch needs its own copy of that step, or you can use a Blocker. See Routing with filters and outcomes.

5. The same workflow in code

Open the Code tab to see what the visual editor wrote. This is the complete workflow:

--#item:
---id:nda_type
---title:What kind of NDA do you need?
---action:question
---options:Is the NDA one-way or mutual?
---answer1|text:One-way
---answer2|text:Mutual
---filter1|filter:answer EQUALS One-way
---filter1|outcome:make_one_way
---filter2|filter:answer EQUALS Mutual
---filter2|outcome:make_mutual

--#item:
---depends_on:nda_type
---id:make_one_way
---alias:nda
---title:Your one-way NDA
---action:auto_document
---options:{one_way_template_key}
---stage:create
---pass_variables:counterparty_IS_{{counterparty_name}}
---outcome:email_legal_1

--#item:
---depends_on:nda_type
---id:make_mutual
---alias:nda
---title:Your mutual NDA
---action:auto_document
---options:{mutual_template_key}
---stage:create
---pass_variables:counterparty_IS_{{counterparty_name}}
---outcome:email_legal_2

--#item:
---depends_on:make_one_way
---id:email_legal_1
---action:auto_email
---to:legal@example.com
---subject:New NDA with {{counterparty_name}}
---body:A one-way NDA has been created.~~~{{document_url_base}}{{nda}}

--#item:
---depends_on:make_mutual
---id:email_legal_2
---action:auto_email
---to:legal@example.com
---subject:New NDA with {{counterparty_name}}
---body:A mutual NDA has been created.~~~{{document_url_base}}{{nda}}

Points to notice:

  • Every item has a unique ---id.
  • A connection always has two halves: the earlier item names the next item (---outcome or a filter's |outcome), and the next item names the earlier one in ---depends_on.
  • Both document items share the alias nda, so later steps can refer to {{nda}}, the key of whichever document was created.
  • ~~~ makes a new line in an email body.

6. Add a launch form

The workflow uses {{counterparty_name}}, so that value has to be collected when the task starts. Go to Settings → Extra fields and add a text field named counterparty_name. See Launch forms.

7. Test it

Start a task from your Workspace and work through it. Check each branch. If something doesn't appear when you expect it to, see Testing and troubleshooting.

For AI builders

When building a workflow for a user:

  1. Ask for, or confirm, the template keys and the email addresses. Never invent a template key. Use a placeholder such as {one_way_template_key} and tell the user to replace it.
  2. Write the whole workflow in code, not as a list of clicks.
  3. Check every connection is two-sided: outcome (or filterN|outcome) on the earlier item, and depends_on on the later one.
  4. List every variable the workflow uses that isn't produced by an earlier item, and put it in the launch form.