send_email_to_caller
The send_email_to_caller tool lets the todo execution agent compose and send a follow-up email to the person who called. The AI writes the email subject and body based on the task description and call transcription, but the recipient is always derived from the system — never chosen by the AI.
When It’s Available
Section titled “When It’s Available”The tool is available during todo execution when the TodoType has SendEmailToCaller in its tools list. Organizations configure this when creating todo types.
Tool Definition
Section titled “Tool Definition”SystemTool::SendEmailToCaller => Tool { name: "send_email_to_caller", description: "Sends a follow-up email to the caller. The recipient is automatically derived from the contact associated with the call.", input_schema: { "type": "object", "properties": { "reason": { "type": "string", "description": "Why this email is being sent" } }, "required": ["reason"] },}The AI provides only a reason parameter. The recipient email address comes from the contact record linked to the call.
Execution Flow
Section titled “Execution Flow”AI calls send_email_to_caller({ "reason": "Follow up on appointment request" }) → Look up call → get contact_id → Query contact_email (ordered by is_preferred DESC) → get recipient → GPT-5 composes email: System: task description + "compose a professional email" User: call transcription Output: { subject: String, body: String } → Send via bases::email::send_emailEmail Composition
Section titled “Email Composition”GPT-5 generates both the subject line and body using structured output:
System prompt:
You are composing a follow-up email based on a phone call.
Task: {todo_description}
Compose a professional email with a clear subject line and body textbased on the task and call context.The body should be plain text, suitable for both text and HTML rendering.User prompt: The raw call transcription.
Output schema:
struct ComposedEmail { subject: String, body: String,}Both plain text and HTML email bodies receive the same composed.body — no separate HTML template is used.
Recipient Resolution
Section titled “Recipient Resolution”- Fetch the call’s
contact_id(error if no contact linked) - Query
contact_emailfiltered bycontact_id, ordered byis_preferred DESC - Take the first result as the recipient (error if no email on file)
Error Handling
Section titled “Error Handling”- No
contact_idon the call → error returned to the AI agent - No email address for the contact → error returned to the AI agent
- Email send failure → error propagated, todo marked as
failed
SystemTool Enum
Section titled “SystemTool Enum”SendEmailToCaller is a variant of the SystemTool enum:
pub enum SystemTool { SendEmailToCaller,}| Method | Value |
|---|---|
display_name() | "Send Email to Caller" |
as_str() | "send_email_to_caller" |
from_str("send_email_to_caller") | Some(SendEmailToCaller) |
Tool assignments are stored in the todo_type_tool join table, linking TodoType to SystemTool variants.
Related Pages
Section titled “Related Pages”- Agent Tools Overview — voice and task tool systems
- Todos — todo extraction, approval, and execution pipeline
- Contact — contact email records used for recipient resolution