mirror of
https://github.com/run-llama/template-workflow-basic.git
synced 2026-07-01 20:54:00 -04:00
1.6 KiB
1.6 KiB
Email Workflow Example
This example demonstrates how to build an event-driven, async-first workflow for sending emails using llama-index-workflows. The workflow uses an LLM to generate email content and sends emails to internal recipients only.
Installation
Install all required dependencies (including llama-index-workflows and OpenAI LLM support):
pip install -e .
Usage
Run the workflow from the command line:
python -m basic.workflow \
--sender you@mycompany.com \
--receiver recipient1@mycompany.com \
--receiver recipient2@mycompany.com \
--subject "Quarterly Update" \
--draft "Here's a draft for the quarterly update email."
Note:
- The sender and all receivers must use
@mycompany.comemails. - You must set your
OPENAI_API_KEYin the environment before running.
Workflow Overview
-
prepare_email: Initializes the email client and uses an LLM to generate a fully-formed email from your draft and subject. Emits a
PrepareEmailevent for each receiver. -
send_email: Sends the generated email to each receiver using the internal email client. Updates email statistics.
-
collect_email_stats: Collects results from all send attempts and outputs a summary of successes and failures.
Customization
- Replace the
EmailClientlogic with your own email sending implementation. - Extend the workflow with additional steps or validation as needed.