Quick overview
This workflow powers dynamic character interactions for investigative games. It ingests lore from Google Drive into a vector database, using Google Gemini agents to generate daily briefings, spawn NPCs, and roleplay interrogations via a webhook.
How it works
- Runs on a manual trigger to download a lore PDF from Google Drive, split it into chunks, create Google Gemini embeddings, and store them in an in-memory vector store for retrieval.
- Receives a POST webhook request from the game client containing game state and an
action value (briefing, init, or chat).
- Routes the request based on
action to either generate a morale-based daily intel briefing, create a new NPC profile for the day, or generate an in-character reply to the player’s interrogation message.
- When factual lore is needed (routes, locations, prices, rules, professions), the Gemini agent queries the
Database_Bunker vector-search tool to ground the response in the ingested PDF.
- Maintains short conversation context per player using a buffer memory keyed by
playerId for ongoing chat and NPC interactions.
- Returns the agent output to the caller as clean JSON via the webhook response.
- Optionally, triggers on an n8n chat message to run a standalone Gemini testing agent that also uses
Database_Bunker and returns a JSON reply.
Setup
- Add Google Gemini (PaLM) API credentials for both the chat model and embeddings nodes.
- Add a Google Drive OAuth2 credential and update the Google Drive file URL/ID so the lore PDF is accessible.
- Run the manual “Execute workflow” trigger once to ingest the PDF and populate the in-memory vector store before using the webhook/chat features.
- Copy the webhook URL and configure your game/client to send POST requests with the required fields (including
action, and for chat memory playerId).