Generate RAG-based study flashcards from notes with OpenAI and Slack

Go to Workflow
0 views
Built by Oneclick AI Squad Oneclick AI Squad
Created on August 13, 2026

Description

Quick overview
This workflow turns submitted study notes into a reviewed flashcard deck by chunking the text, retrieving the most relevant passages with OpenAI embeddings, generating grounded Q&A cards with an OpenAI chat model, and sending the approved deck to a Slack channel.

How it works
Receives notes via a POST webhook (or runs manually for testing) and loads the workflow configuration for chunking, retrieval, flashcard count, and Slack delivery.
Splits the notes into overlapping, heading-aware text chunks and pauses to collect the topic or scope you want to generate flashcards for.
Requests OpenAI embeddings in one batched call for the topic query and all note chunks.
Ranks chunks by cosine similarity, applies a diversity-aware selection (MMR), and assembles the retrieved context for generation.
Uses an OpenAI chat model to generate a JSON array of flashcards strictly grounded in the retrieved context.
Validates and deduplicates the generated cards, initializes SM-2 scheduling fields, then pauses for human review and final export approval.
Sends the approved flashcard deck to the configured Slack channel, or marks the run as discarded if review/export is declined.

Setup
Add OpenAI credentials for both embeddings and chat completion, and confirm the embeddings model and chat model selections match your account access.
Add Slack API credentials with permission to post messages, and set the target channel name in the configuration (for example, #flashcards).
If using the webhook trigger, copy the webhook URL from n8n and configure your notes source to POST a notesText field (and optionally topic, reviewApproved, and exportApproved) to that endpoint.

Nodes Used (5)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
HTTP Request
n8n-nodes-base.httpRequest
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Slack
n8n-nodes-base.slack