Guide: Send a document request

An applicant is missing a pay stub. This guide goes from "what have we already asked them?" to a
message on its way — checking the template renders correctly before anyone receives it, and
writing a new one only if none fits.

Reads here are PII-filtered and masked. Your assistant sees that a message was sent, when, and
whether there was a reply; it does not see the applicant's name, address, email, or phone number,
and message bodies come back with addresses, phone numbers, and SSNs replaced by [email],
[phone], [ssn].

Before you start

  • The application's session UUID, from the portal.
  • A Live connection. Sending contacts a real person and requires a live-mode token.
  • Permission on the Agent Dashboard module to send, and on Templates to author.

The prompts below are what you type. The tool noted underneath is what your assistant runs.


Step 1 — See what they have already been told

For LendAPI application <session-uuid>, what have we already sent and did they reply?

Tools: app_get_documents, app_list_conversations

app_get_documents tells you what is actually missing. app_list_conversations returns every
email thread and SMS exchange on the application as one list, newest first, with status, unread
flags, and timestamps.

Read the timeline before you decide:

Show me the messages in the most recent email thread, with bodies.

Tool: app_get_conversation_messages with include_body=True

If they were asked two days ago and have not replied, a short SMS nudge beats a second email. If
nobody has asked at all, send the email.

The sources block tells you what is available: sms: disabled means the tenant has no SMS
number, and sms: no_phone means this applicant has none on file.

Step 2 — Find a template that fits

List our published, active email templates about documents.

Tool: comms_list_templates with template_type="email", published=True, active=True,
search="document"

Then read the one that looks right:

Show me that template's content and whether it can be sent.

Tool: comms_get_template

The field that decides everything is sendable. A template sends only when it is published,
active, and has a default version — sendable_blockers names whatever is missing
(inactive, not_published, no_default_version, empty_body, empty_subject).

Also read to_emails. ids are fixed addresses; engine_name entries are application variables
that hold an address, resolved per application at send time. If both are empty, the template has
nobody to send to.

If a template fits and is sendable, skip to Step 5.

Step 3 — Write one, if nothing fits

Create an email template called "Pay stub request" for asking about missing income documents.

Tool: comms_create_template

You get back a session — the id every other template tool takes. The draft is empty and
unpublished, so nothing can be sent with it yet.

Give it the subject "Documents needed for your application", a short body that greets them by
first name and lists what is missing, and send it to the applicant's email.

Tool: comms_update_template

Before this call reaches LendAPI, your assistant checks every {{placeholder}} in the subject and
body against the tenant's variables. This matters: LendAPI renders an unknown placeholder as an
empty string rather than failing, so {{frist_name}} would quietly ship as "Hello ,". If a
placeholder does not exist, either fix the spelling or create the variable with
variables_create_simple. On a tenant with more than 1000 variables the check cannot read them
all: placeholders it could not confirm are saved and listed in placeholder_warning, so render the
template with comms_preview_template to confirm them.

The draft is a draft. Live sends keep using whatever version is currently default until you
publish.

Step 4 — Check it, then publish

Render it with "Sam" as the first name and 2 as the document count.

Tool: comms_preview_template

Read the rendered subject and body, and check unresolved_placeholders is empty — anything listed
there will render blank for a real applicant.

For copy a customer will actually read, a rendered preview is often not enough. Send yourself a
real one:

Test-send it to me at <your work email>.

Tool: comms_test_send

The target must be a staff member of your tenant — a test send is refused for any other address,
so it can never reach an applicant by accident. Attachments are not included; check those in the
studio.

Publish it as the default version, noting that it is the first draft.

Tool: comms_publish_template with set_default=True

Publishing snapshots the draft as a new version. With set_default=True that version is what
every send uses from now on. If the template is still switched off:

Turn the template on.

Tool: comms_toggle_template_active with active=True

Step 5 — Send it

Send that template to application <session-uuid>.

Tool: app_send_email

This contacts a real person and cannot be recalled — your client should ask you to confirm.

Two things worth knowing:

  • You cannot invent a recipient. Addresses come from the template. If you pass to, every
    address in it must already be on the application or the template, and addresses the template
    already resolves are not sent to twice. The response tells you recipient_count, never the
    addresses themselves.
  • status: "queued" means queued, not delivered. The send happens in the background.

For a short nudge instead:

Text them the reminder template.

Tool: app_send_sms

An SMS always goes to the applicant's own phone — it cannot be redirected — and returns
status: "sent" only when the messaging service accepted it. Unlike email, an SMS renders the
template's current draft text, so it needs an active template but not a published version. Keep
custom text under 320 characters.

Step 6 — Record it and watch for the reply

Note on the application that I requested a pay stub, then check tomorrow whether they replied.

Tools: app_add_note, then app_list_conversations

The note is for the human underwriter who picks this up next. The conversation list is where the
reply will show up.


Rolling back a bad template

If a published version turns out to be wrong:

List the versions of that template and put version 2 back as the default.

Tools: comms_list_template_versions, comms_set_default_version

Promoting a version takes effect immediately — the next send uses it. If the template itself
should stop sending entirely, comms_toggle_template_active with active=False switches off
every automatic trigger that uses it, while keeping the content and version history. Be careful:
that also stops outcome and journey triggers other people may rely on.


See also


Did this page help you?