ChatCompletion icon
MailSend icon

Generate a book chapter summary using Perplexity AI and email it.

Automate book chapter summaries with Kestra and Perplexity AI. Generate a search-grounded recap, format it as HTML, and email the result in one flow.

Categories
AI

Turn any book chapter into a clear, search-grounded summary delivered straight to your inbox. This Kestra flow chains two Perplexity AI calls and an SMTP send so you can read a chapter, capture what it covered, and get a polished recap email without copy-pasting prompts or wrangling output formats by hand. It is a practical pattern for AI summarization, retrieval-augmented recaps, and automated email delivery built entirely from declarative YAML.

How it works

  1. You provide two inputs: book (a STRING, defaulting to "The Hunger Games by Suzanne Collins") and chapter (an INT for the chapter you just finished).
  2. The get_chapter_summary task calls io.kestra.plugin.perplexity.ChatCompletion with a SYSTEM prompt that asks for a clear, concise summary mixing paragraphs and bullet points, and a USER prompt built from your book and chapter inputs. The search-grounded sonar model keeps the recap factual.
  3. The convert_to_html task feeds {{ outputs.get_chapter_summary.rawResponse }} into a second ChatCompletion call that reformats the plain summary into a clean HTML snippet and appends a Resources section linking the sources Perplexity used.
  4. The send_summary task uses io.kestra.plugin.email.MailSend to deliver {{ outputs.convert_to_html.outputText }} over Gmail SMTP (smtp.gmail.com, port 465) with a subject line built from the book title and chapter number.
  5. A pluginDefaults block applies the Perplexity apiKey, model: sonar, and temperature: 0.7 to every ChatCompletion task so configuration stays in one place.

What you get

  • A factual, readable chapter recap generated by a search-grounded LLM.
  • An email-ready HTML version with a linked Resources list.
  • A single end-to-end run from raw input to delivered email, no manual steps.

Who it's for

  • Readers and students who want quick comprehension checks after each chapter.
  • Developers learning how to chain LLM calls and notifications in Kestra.
  • Teams prototyping AI summarization and digest-email patterns.

Why orchestrate this with Kestra

Perplexity's API answers one prompt at a time and has no scheduler, no retry logic, and no memory of prior steps. Kestra wraps the whole chain in declarative YAML: you can add event or schedule triggers to summarize on a cadence, set retries on the API and SMTP tasks for transient failures, and pass outputs between tasks with clear lineage from input to delivered email. The orchestrator handles the glue that the LLM API alone cannot.

Prerequisites

  • A Perplexity API key with access to the sonar model.
  • A Gmail account with an app password for SMTP delivery (or adjust host, port, from, and to for another provider).

Secrets

  • PERPLEXITY_API_KEY: authenticates the Perplexity ChatCompletion tasks.
  • G_EMAIL: the SMTP username for the sending Gmail account.
  • G_APP_PASSWORD: the Gmail app password used as the SMTP password.

Quick start

  1. Add the PERPLEXITY_API_KEY, G_EMAIL, and G_APP_PASSWORD secrets to your Kestra instance.
  2. Update the from and to addresses in the send_summary task to your own email.
  3. Execute the flow, entering your book title and the chapter number.
  4. Check your inbox for the formatted summary email.

How to extend

  • Swap the prompts to summarize articles, meeting transcripts, PDFs, or release notes.
  • Replace the email task with a Slack or Microsoft Teams notification.
  • Add a schedule trigger to send a daily or weekly reading digest.
  • Store each summary in object storage or a database for a searchable archive.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.