docs
/
AI skills

New-lead follow-up automation

When a lead arrives in a pipeline, it gets its owner, a welcome email from a message template and one of the business's email accounts, and a follow-up task if the lead hasn't replied after a set number of days.

This job is one automation, plus the pieces it needs: who owns the lead, what the email says and which address it comes from. The automation emails real people the moment it is on, so it is built as a draft and a person turns it on.

Ask first

  • Which pipeline? By name. Find it (find_records on lead_pipeline) and take its sk. If there is none, do Set up lead acquisition first.
  • Who should own new leads? If the pipeline's assignment rules already answer this, say who they give leads to and confirm.
  • What should the welcome say? The words, or what it should say if the AI writes it.
  • From which address? One of the business's email accounts.
  • How many days without a reply before a follow-up task? And who gets the task: name a person.

Steps

1. Leads: the owner

New leads get their owner from the pipeline's assignment rules the moment they arrive, before any automation runs. Owning is done there, not in the automation. Read the pipeline's assignmentRules and make sure the last one is a catch-all (empty criteria), so no lead is left without an owner. To change them, see step 3 of Set up lead acquisition.

Don't add an assign_to_user step to the automation. It writes the owner straight onto the record without the lead service, so no history line and no notice to the new owner.

Hands on: the pipeline's sk. Check: on the board (/leads?pipeline=<pipeline sk>), the Assignment button shows the rules.

2. Message Templates: the welcome

Create a messagetemplate (create_record):

FieldValue
nameletters, digits, - or _, unique, e.g. lead-welcome
deliveryTypeemail
subjectthe subject line
htmlthe message

For the lead's own details, use {{data.<lead field>}}: {{data.firstName}}, {{data.fullName}}, {{data.company}}. Use only lead fields that exist (get_schema on lead).

Hands on: the template's sk. Check: open it (/message-template?openId=<template sk>). The editor shows a live preview, and its test send goes to the person, not to a lead.

3. Email Accounts: the sender

Find the email_account it should come from and take its emailAddress. When the address is one of the business's hosted mailboxes, the email goes out through that mailbox. Otherwise it goes out through the business's email sending service, which uses its own from-address.

Hands on: the account's emailAddress. Check: the account exists and is active (/email-accounts). If the business has no account, say so: the automation can be saved, but sending will fail until one is added.

4. Automation: the draft

Call list_automation_capabilities and list_automations first, so you use names that run and don't build a second copy. Then create_automation with status: "draft":

  • trigger: database_change, { datatype: "lead", operation: "created" }. It fires for a lead from any pipeline, so the first step checks the pipeline.
  • steps (give each its id, because the conditions jump to them):
idtype / nameconfig
in_pipelinecondition if_thencondition: { field: "record.data.pipelineId", operator: "equals", value: "<pipeline sk>" }, thenStepId: "welcome", elseStepId: "done"
welcomeaction send_emaildeliveryType: "email", to: "{{data.email}}", templateIds: ["<template sk>"], from: "<account emailAddress>"
wait_replyaction wait_for_replymessageType: "any", maxWait: <days>, maxWaitUnit: "days", timeoutAction: "continue"
no_replycondition if_thencondition: { field: "reply.from", operator: "not_exists" }, thenStepId: "task", elseStepId: "done"
taskaction create_tasktitle: "Follow up with {{data.fullName}}", description: "No reply <days> days after the welcome email.", priority: "high", assignedTo: "<person's email>"
doneend end_flownone

How it behaves:

  • wait_for_reply pauses the run. It wakes early when an email or text from the lead's address arrives in the business's inbox. A reply counts only if it reaches the system, through an email account set to receive mail. A reply to an address the system doesn't read is never seen.
  • After a reply, reply.from is set and the run ends without a task. After the full wait with no reply, the task is created.
  • The task belongs to the lead (it is about the lead) and its assignee gets a notice.

Calling the lead, and trying again

A make_call step has AI talk with the person — an AI Assistant (fast; the default) or an AI Employee (calls as itself, slower to start). There is no recorded or synthesized message.

configwhat it does
tothe number — {{data.phone}} for a lead
reasonwhat the call is for — the AI works from it (required)
greetingthe opening line (optional)
assistantIdthe AI Assistant (empty = the calling number's, else the main one)
aiEmployeean AI Employee's address instead — it calls in its own voice
waitForResult: truethe run waits until the call ends; the next steps can use call.outcome: answered, no-answer, busy, failed, canceled (or unknown if no result came in 30 minutes)
attempts: 1–5when nobody answers, call again — this many tries in all
retryAfterMinutesthe wait between tries (default 120)
callingHours: { from: "09:00", to: "18:00", weekdaysOnly }calls and tries only inside these hours, in timezone (else the lead's, else UTC)

After it, branch with a condition on call.outcome — e.g. { field: "call.outcome", operator: "not_equals", value: "answered" } → send a text; answered → move the stage or create a task. call.attempt is the try that ended it.

Trigger email_clicked with emailId: "<broadcast sk>" and, for one link only, linkUrl: "<any part of the address>". It runs once per person per email, for their lead (else their customer record) — data is that record, event.link the address they clicked. email_opened works the same way (opens are less reliable: some mail apps open every email).

Stop: turning this on emails every new lead in that pipeline. Show the person:

  • the pipeline;
  • the subject and first lines of the welcome;
  • the from-address;
  • the wait in days, and who gets the follow-up task.

Turn it on only after a clear yes, with call_appengine POST /automation/start/<automation sk>. set_automation_status → active saves the status but doesn't connect the trigger, so the automation wouldn't run (see Automation when a record is added or updated). A draft never runs. If the business sends through the shared email service, sending also needs its service agreement; without it the email step fails.

Hands on: the automation's sk. Check: open it in the builder (/automation?openId=<automation sk>). After it is on, the first lead's run shows on its monitor (/automation?monitor=<automation sk>), waiting at the reply step.

When it's done

Tell the person:

  • the pipeline it watches;
  • who new leads go to (the assignment rules);
  • the welcome template and the from-address;
  • the number of days, and who gets the follow-up task;
  • whether it is on, or waiting in Automation as a draft.

Open the automation in the builder.

What it can't do yet

  • "Quiet" means no reply, nothing else. A call logged or a stage move doesn't stop the task. After a wait, the run sees the lead as it was when it arrived. It can't check whether the lead has since moved on. Say so if the person means "no progress" rather than "no reply".
  • The task can't go to the lead's owner by itself. The run starts from the lead as first saved, and the owner is set just after that save, so {{data.assignedTo}} is not reliable. Name a person.
  • Stage time limits don't cover the first stage. A stage's sla ({ duration: <hours>, action: "create_task" }) creates a task for leads stuck in that stage. It counts from when the lead was moved into the stage, so a lead that never left its first stage is never caught.

Don'ts

  • Don't create it active, even though create_automation defaults to active. Always pass status: "draft".
  • Don't write {{lead.name}} or {{contact.email}}. Only {{data.<field>}} and {{record.…}} exist in a lead-created run.
  • Don't promise discounts, prices or dates in the welcome that the person didn't give you.