Mindket

Illustrated history PDF book from a Telegram message

Newversion 1 · updated

Overview

An n8n workflow that turns a history topic sent to a Telegram bot into an illustrated PDF book. OpenAI checks the topic and writes the chapters, Kie.ai draws a picture for each, and APITemplate.io makes the PDF for Google Drive.

Illustrated history PDF book from a Telegram message is an n8n workflow in the Marketing & SEO category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file, add four credentials, two keys and a Cloudinary preset, then publish
  • Your own n8n server: the same steps, with the server reachable over https
  • Telegram: one bot, which answers anyone unless you restrict it
  • Google Drive and Google Sheets: the PDF in the root of My Drive, and a row for the book and for each picture

Platform

Connects 7 apps

How it works

Trigger

Telegram message

It starts when someone sends your bot a text message with:

  • A topic in history, a life story or an educational concept, in a few words

Actions

  1. An OpenAI model checks the topic and turns away anything outside history and education
  2. The book gets a row in Google Sheets with a new ID
  3. gpt-5.1 searches the web and writes five to twenty dated chapters with image prompts
  4. Kie.ai draws a picture for each chapter, and Cloudinary hosts it
  5. APITemplate.io turns the chapters into an A4 PDF, one page each
  6. The PDF is saved to Google Drive and its link written to the sheet

Result

An illustrated PDF book in your Drive, and a sheet row with its link, from one Telegram message

Integrations

What you need before you start.

Telegram

Chat trigger

Takes each message sent to your bot, and replies when a topic is turned away or a file is sent.

NeedsA Telegram bot token from BotFather

OpenAI

Language models

Runs gpt-4.1-mini to check the topic and gpt-5.1 with web search to write the chapters.

NeedsOpenAI API key

Kie.ai

Image generation

Draws one wide picture for each chapter with Nano Banana Pro and reports the task’s state.

NeedsKie.ai API key, typed into two headers, and credit

Cloudinary

Image hosting

Takes each picture through an unsigned upload and returns the public address the PDF shows.

NeedsA cloud name and an Unsigned upload preset

APITemplate.io

PDF rendering

Renders the chapter pages from HTML into an A4 PDF and returns its download address.

NeedsAPITemplate.io API key, typed into the node’s header

Google Sheets

Job log

Holds a row for the book and one for each picture, with their statuses and links.

NeedsA Google account to sign in with, and a sheet with eight headers

Google Drive

PDF storage

Saves the finished PDF in the root of My Drive.

NeedsA Google account to sign in with

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
29 steps, starting on a Telegram event
AI
2 steps call an AI model: AI Agent1 and AI Agent
Sign-ins
Signs in to: Telegram, Google Sheets, Google Drive, OpenAI, Kie.ai and APITemplate.io
API keys
No API key is left in the file; 2 blanks in it for your own key
Step types
Mindket’s checker reads all 16 of its step types

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow turns a topic sent to a Telegram bot into an illustrated PDF book about it. A small OpenAI model first checks that the topic is history, a life story or an educational concept. A larger one, gpt-5.1 with web search, then writes between five and twenty chapters in date order, each with a paragraph and an image prompt. Kie.ai draws a picture for every chapter with Nano Banana Pro, Cloudinary hosts it, and APITemplate.io lays the chapters out as A4 pages, one chapter a page. The PDF lands in Google Drive. A sheet tracks the book and each picture. It has 37 nodes.

  1. Telegram takes a topic and OpenAI checks it
  2. OpenAI researches it and writes up to 20 chapters
  3. Kie.ai draws one picture for each chapter
  4. APITemplate.io turns the pages into an A4 PDF
  5. Drive keeps the PDF and the sheet gets its link

Who it suits

Teachers, tutors, history channels and makers of digital products who want a picture book on a topic without laying it out by hand. One message gives a finished booklet, so it suits handouts, lead magnets and study guides. Skip it when the facts must be sourced. The chapters cite nothing. The classifier also turns away topics outside history and education. Read each PDF before you share it.

Who uses it, and how
IndustryWho uses itHow they use itExample
EducationTeachersSend a unit’s topic the night before a lessonA teacher prints the booklet on the French Revolution as a class handout.
TutoringPrivate tutorsMake a short reader for each student’s exam topicA tutor sends a student a guide to the Cold War, a page for each turning point.
Digital productsCreators who sell PDFsTest a topic with a sample booklet before writing a longer oneA creator offers a booklet on ancient Rome as a free download.
History on YouTubeChannel ownersDraft a dated outline and stills for an episodeA channel owner uses the chapter dates as the running order.

You need some n8n and six accounts, for Telegram, OpenAI, Kie.ai, Cloudinary, APITemplate.io and Google, and its author puts setup at about 24 minutes once they are ready.

Where to use it

Any n8n on a public https address will run it, since Telegram delivers each message to a webhook. Everything it makes ends in your Drive and your sheet.

  • n8n Cloud: import the file, add four credentials, two keys and a Cloudinary preset, then publish
  • Your own n8n server: the same steps, with the server reachable over https
  • Telegram: one bot, which answers anyone unless you restrict it
  • Google Drive and Google Sheets: the PDF in the root of My Drive, and a row for the book and for each picture

Setup

Get it saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Make the sheet and the Cloudinary preset first.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server of your own, reachable over https
TelegramA bot and its token, from BotFather
OpenAIAn API key with access to gpt-5.1 and gpt-4.1-mini
Kie.aiAn API key with credit, for Nano Banana Pro
CloudinaryA cloud name and an unsigned upload preset
APITemplate.ioAn API key
GoogleAn account for a Google Sheets OAuth2 and a Google Drive OAuth2 credential
A sheetA first tab named Sheet1 with eight headers in row 1
The sheet’s headers
ColumnWhat it holds
IDA UUID for the book or for one picture
Parent IDOn a picture’s row, its book’s ID
ConceptOn the book’s row, the topic as the classifier rewrote it
TypeBriefing Job for the book, Asset Creation for a picture
StatusQueued, Generating... or Completed
PromptOn a picture’s row, its image prompt
Public LinkOn a picture’s row, its Cloudinary address
PDF LinkOn the book’s row, the PDF’s Drive link
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. Make the sheet and copy its ID: the long part of its address between /d/ and /edit.
  3. Add a Telegram credential with your bot’s token and select it in Telegram Trigger, Send a text message and Send a text message1.
  4. Add an OpenAI credential and select it in OpenAI Chat Model and OpenAI Chat Model1.
  5. Add a Google Sheets OAuth2 credential, select it in the five sheet nodes and replace YOUR_SHEET_ID in each with the ID.
  6. In nano-banana-pro and nano-banana-pro-result, replace <YOUR_KIE_API_KEY> after Bearer with your Kie.ai key. The brackets go too.
  7. In Upload Photo, put your cloud name in place of <YOUR_CLOUD_NAME>, brackets included, and your preset and a folder in place of YOUR_PRESET_NAME and YOUR_FOLDER_NAME.
  8. In HTML to PDF, replace <YOUR_APITEMPLATE_API_KEY> in the X-API-KEY header with your key, brackets included.
  9. Add a Google Drive OAuth2 credential and select it in Upload PDF.
  10. Save, press Publish and send your bot a short topic.

HTML to PDF calls APITemplate.io’s US region, rest-us, so change the address if your account sits in another one. Set Restrict to User IDs in Telegram Trigger before anyone else learns the bot’s name.

How to use it

Send the bot a topic in a few words, such as the moon landing. Other subjects get a short refusal. A valid one runs by itself, and the sheet shows the book’s row and then a row for each picture as it is drawn. A long book takes ten minutes or more, since every picture waits at least 30 seconds. Open the PDF Link once the book’s row reads Completed, because the bot sends nothing when the book is done.

What to change for a different result
To changeWhere
Which topics passThe system message in AI Agent1
The chaptersThe system message in AI Agent: how many, how long and in what voice
The picturesaspect_ratio, resolution and output_format in the body of nano-banana-pro
The page designThe HTML and CSS in HTML, including the fonts and the footer
Paper and marginssettings in the body of HTML to PDF
Where the PDF goesThe drive and folder in Upload PDF, the root of My Drive in the file

Example

You send the bot one line.

the moon landing

AI Agent1 rewrites it as a title such as The Apollo 11 Moon Landing, and Create Job adds the book’s row. AI Agent then returns chapters like this one, trimmed:

{
  "chapter_id": 4,
  "title": "One Small Step",
  "date": "July 1969",
  "content": "Neil Armstrong climbed down the ladder of the lunar module and stepped onto the Sea of Tranquility...",
  "image_prompt": "An astronaut in a white suit steps off a ladder onto grey dust under a black sky, a sign beside the lander reading July 1969."
}

Each chapter becomes one page with its title, a date badge, the picture, the paragraph and a footer with its ID. At the end, the book’s row reads like this:

The book’s row at the end
ColumnValue
ConceptThe Apollo 11 Moon Landing
TypeBriefing Job
StatusCompleted
PDF LinkA Drive link to the PDF, named after the topic and the ID

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. A credential is a key n8n keeps for you and hands to the node you pick it in. Here four notes on the canvas mark the stages: checking the topic, writing the chapters, drawing the pictures and making the PDF. Send a small topic first and watch the sheet fill. Each node shows what it received and what it sent, which is where a refused key or a failed picture turns up.

For experts. Two OpenAI agents with structured output parsers write the text, and Kie.ai and APITemplate.io do the rest through plain HTTP requests from n8n.

What each stage does
NodeModel or callWhat to know
AI Agent1gpt-4.1-miniReturns is_valid, refined_topic and reply_to_user, and an If reads is_valid
AI Agentgpt-5.1 with OpenAI’s built-in web searchIts parser wants chapters, each with title, date, content and image_prompt
nano-banana-proKie.ai’s jobs/createTask, model nano-banana-proA 16:9 PNG at 1K, with no reference image
SwitchThe Kie.ai task’s stateWaiting, queuing and generating loop back to Wait, success moves on and fail goes nowhere
HTML to PDFAPITemplate.io’s v2/create-pdf-from-htmlA4 with backgrounds printed. Its body was repaired, see Good to know

Merge joins the queued rows with the chapters on id. Edit Fields then hands the loop each chapter with its picture’s address.

Good to know

The finished book stays in your Drive and your sheet. Nobody is told on Telegram.

  • No reply on success: the run ends at the sheet. Add a Telegram send after Update row in sheet2 with PDF Link if the person who asked should get the book
  • Open to anyone: the bot answers every message, and each book spends OpenAI, Kie.ai and APITemplate.io credit. Set Restrict to User IDs in Telegram Trigger
  • Retired models: OpenAI shuts down gpt-4.1-mini on 14 January 2027, with gpt-6-luna as the replacement, and gpt-5.1 on 1 April 2027, with gpt-6-sol
  • A repair: the original copy had lost two backslashes in the body of HTML to PDF. As exported, it deleted every letter n from the page and left its quotes unescaped, so the call could not succeed. The kit puts them back
  • A failed picture: Switch sends fail nowhere, so the loop stops, no PDF is made and the rows stay at Generating...
  • Other messages: only documents are turned away. A photo or a voice note reaches AI Agent1 with no text, and the run fails without a reply
  • One look: the chapter prompt speaks of a reference image for the art style, but none is sent, so each picture’s style is the model’s choice
  • Public files: the pictures sit at public Cloudinary addresses, and APITemplate.io keeps the PDF on its CDN with no expiry unless you set one
  • Costs: Kie.ai bills each picture. OpenAI bills both agents and the web searches
  • Your data: the topic and the chapters go to OpenAI, the prompts to Kie.ai and the pages to APITemplate.io
  • Credentials: the JSON holds none, and nothing from its author’s sheet

README and files

README

Illustrated history PDF book from a Telegram message

An n8n workflow that turns a history topic sent to a Telegram bot into an illustrated PDF book. A small OpenAI model
checks that the topic is history or an educational concept. A larger one researches it on the web and writes between 5
and 20 chapters, each with a date and an image prompt. Kie.ai draws one picture per chapter with Nano Banana Pro, and
APITemplate.io lays the chapters out as A4 pages. The PDF goes to your Google Drive, and a Google Sheet tracks the book
and every picture.

What is inside

  • workflow.json: the workflow as n8n exports it, 37 nodes. Four are sticky notes that only name the stages. It holds
    no credential.
  • README.md: these notes.

What we changed from the original copy

  • The author's sheet and its tab id are gone. The five sheet nodes ask for YOUR_SHEET_ID and find the tab by the name
    Sheet1.
  • The Kie.ai headers read Bearer <token>. They now read Bearer <YOUR_KIE_API_KEY>. The APITemplate.io header now
    reads <YOUR_APITEMPLATE_API_KEY>.
  • The Telegram, OpenAI, Google Sheets and Google Drive credentials are gone, along with the author's account names on
    them, and so are the Telegram nodes' webhook ids.
  • A repair in HTML to PDF: the export had dropped two backslashes from its body. It read .replace(/"/g, '\"') and
    .replace(/n/g, ''), which left every double quote in the HTML unescaped and deleted every letter n from the page.
    It now reads .replace(/"/g, '\\"') and .replace(/\n/g, ''), as the step needs to send valid JSON.
  • The Cloudinary placeholders, <YOUR_CLOUD_NAME>, YOUR_PRESET_NAME and YOUR_FOLDER_NAME, were already in the file.

Before you start

  • An n8n instance, on n8n Cloud or your own server. A Telegram trigger needs n8n on a public https address.
  • A Telegram bot and its token, from BotFather.
  • An OpenAI API key with access to gpt-5.1 and gpt-4.1-mini.
  • A Kie.ai API key with credit.
  • A Cloudinary account with an unsigned upload preset.
  • An APITemplate.io API key.
  • A Google account to sign in to Sheets and Drive with, and a Google Sheet with the tab below.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. Make a Google Sheet whose first tab is named Sheet1, with the eight headers below in row 1. Copy its ID: the long
    part of its address between /d/ and /edit.
  3. Add a Telegram credential with your bot's token and select it in Telegram Trigger, Send a text message and
    Send a text message1.
  4. Add an OpenAI credential and select it in OpenAI Chat Model and OpenAI Chat Model1.
  5. Add a Google Sheets OAuth2 credential. Select it in Create Job, Append row in sheet2, Update row in sheet,
    Update row in sheet1 and Update row in sheet2, and replace YOUR_SHEET_ID in each with the ID.
  6. In nano-banana-pro and nano-banana-pro-result, replace <YOUR_KIE_API_KEY> after Bearer with your Kie.ai key.
    The brackets go too.
  7. In Cloudinary, make an unsigned upload preset. In Upload Photo, replace <YOUR_CLOUD_NAME> in the address with
    your cloud name, brackets included, and put the preset's name and a folder name in place of YOUR_PRESET_NAME and
    YOUR_FOLDER_NAME.
  8. In HTML to PDF, replace <YOUR_APITEMPLATE_API_KEY> in the X-API-KEY header with your key, brackets included.
    The address uses APITemplate.io's US region. Change rest-us to the region your account uses if it differs.
  9. Add a Google Drive OAuth2 credential and select it in Upload PDF. The file goes to the root of My Drive.
  10. Save and press Publish. Send your bot a short topic, such as the moon landing.

The sheet

Row 1 of Sheet1 holds these eight headers, spelled as here. A book takes one row and each of its pictures one more:

| Column | The book's row | A picture's row |
|---|---|---|
| ID | A new UUID | A new UUID |
| Parent ID | Empty | The book's ID |
| Concept | The topic as the classifier rewrote it | Empty |
| Type | Briefing Job | Asset Creation |
| Status | Generating..., then Completed | Queued, Generating..., then Completed |
| Prompt | Empty | The image prompt |
| Public Link | Empty | The picture's Cloudinary address |
| PDF Link | The PDF's Drive link | Empty |

How a run goes

  1. Telegram Trigger takes every message sent to the bot. File Check answers a document with Files not supported.
  2. AI Agent1, on gpt-4.1-mini, decides whether the text is a history or education topic. If it is not, the bot
    replies with a short refusal the model writes, and the run ends.
  3. A valid topic gets a UUID from Crypto1, and Create Job adds the book's row with the rewritten topic.
  4. AI Agent, on gpt-5.1 with OpenAI's web search, writes 5 to 20 chapters in date order. Each has a title, a date,
    a paragraph of three or four sentences and an image prompt that names the text to show in the picture.
  5. Split Out and Crypto give each chapter its own UUID, and Append row in sheet2 queues a row for it.
  6. Loop Over Items takes one chapter at a time. nano-banana-pro asks Kie.ai for a 16:9 PNG at 1K. Wait pauses 30
    seconds, nano-banana-pro-result asks for the task's state and Switch routes it: still working waits again, done
    moves on.
  7. download-image fetches the picture, Upload Photo puts it on Cloudinary, and Update row in sheet1 marks the row
    Completed with its address.
  8. When every chapter is done, Aggregate and HTML build one page per chapter: the title, a date badge, the picture,
    the paragraph and a footer with the chapter's ID.
  9. HTML to PDF sends the page to APITemplate.io as an A4 PDF, Download PDF fetches it and Upload PDF saves it to
    Drive, named after the topic and the book's ID. Update row in sheet2 marks the book Completed with the Drive link.

Change the style

  • Which topics pass: the system message in AI Agent1.
  • The chapters' number, length and voice: the system message in AI Agent.
  • The pictures: aspect_ratio, resolution and output_format in the body of nano-banana-pro.
  • The page design: the HTML and CSS in HTML, including the fonts and the footer's text.
  • Paper and margins: settings in the body of HTML to PDF.
  • Where the PDF goes: Upload PDF's drive and folder.

Good to know

  • The PDF never reaches Telegram. On success the run ends at the sheet, and the person who asked gets no message. Add
    a Telegram send node after Update row in sheet2 with PDF Link if they should get it.
  • Open to anyone: the bot answers every message from anyone who finds it, and each book spends OpenAI, Kie.ai and
    APITemplate.io credit. Set Restrict to User IDs in Telegram Trigger to your own ID.
  • Retired models: OpenAI shuts down gpt-4.1-mini on 14 January 2027, with gpt-6-luna as the replacement, and
    gpt-5.1 on 1 April 2027, with gpt-6-sol. Change OpenAI Chat Model1 and OpenAI Chat Model before those
    dates.
  • A failed picture stalls the book: Switch sends a fail state nowhere, so the loop stops there. No PDF is made,
    the rows stay at Generating... and nobody is told.
  • Other messages: only documents are turned away. A photo, a sticker or a voice note reaches AI Agent1 with no text,
    and the run fails there without a reply.
  • No style picture: the prompt in AI Agent says an outside reference image sets the art style, but nano-banana-pro
    sends none. Each picture's style is the model's choice. Kie.ai's image_input takes up to eight reference images if
    you want one look.
  • Public files: each picture sits at a public Cloudinary address, and APITemplate.io keeps the PDF on its own CDN,
    with no expiry unless you set one. The Drive link works only for people who can see the file in your Drive.
  • Costs: Kie.ai bills every picture, one for each chapter. OpenAI bills both agents, plus the web searches.
    APITemplate.io counts each PDF against your plan.
  • Time: each picture takes at least 30 seconds of waiting, so a long book runs for ten minutes or more.
  • Your data: the topic and the chapters go to OpenAI, the image prompts to Kie.ai and the pages to APITemplate.io.
  • Credentials: the JSON holds none, and nothing from its author's sheet.
Files
README.md  8 KB
workflow.json  48 KB

2 files, 56 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-03

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

Huashu Design

alchaincyf · Skill

Turns a one-line request in your AI agent into a finished design: a launch animation, a clickable app prototype, an editable slide deck, an infographic or a se…

New29.4k

Guizang PPT Skill

op7418 · Skill

Skill that makes single-file HTML slide decks, slide illustrations and platform covers in two visual styles, with a presenter mode for rehearsal. For speakers…

New29.8k

Claude Code Skills & Plugins

alirezarezvani · Skill

Adds 411 ready-made skills for Claude Code and other coding agents, grouped by role from engineering and product to marketing, finance and compliance. Installs…

New29.8k

Similar in Marketing & SEO

See all in Marketing & SEO

Pixel Art XL

nerijs · Kit

A pixel art style add-on for Stable Diffusion XL that turns text prompts into pixel-style images, with an optional LCM LoRA for faster runs. For game makers, d…

New

Licon MSR for LTX-2.5

LiconStudio · Kit

Keeps characters, clothing, objects and backgrounds consistent in generated video by feeding the model up to five reference images. A LoRA for LTX-2.5 in Comfy…

New

Flux.2-Klein-9B-MatchingPose

nhathoangfoto · Kit

A LoRA for FLUX.2 Klein 9B that puts a character into the pose shown by a mannequin reference while keeping the character's face and style. For artists and des…

New