Hi all,
I’m currently building a Personal Assistant workflow in n8n that uses:
OpenAI (GPT-3.5) to process Tavily web search results and generate clean summaries,
Followed by a Google Drive node (Create file from text) to save those results,
With dynamic file naming based on the summary title.
What’s working so far:
The GPT node (set to Text output mode) returns results like this:
Recent News on Autonomous Agents
The full text is saved successfully as file content in Drive.
The confirmation message is returned correctly to the user. issue is file name always returns to default.
In the Google Drive node’s File Name field, I’m using this expression:
js
Copy
Edit
{{ ($json.text.match(/^ *## +(.+)/m) || [null, ‘WebSearch’])[1] }}_{{ $now.format(“YYYY-MM-DD_HH-mm”) }}.txt
However, even when the GPT response clearly includes a markdown heading (e.g., ## Recent News on Autonomous Agents), the Drive file still gets named like:
WebSearch_2025-07-30_15-20.txt
I’ve confirmed GPT is returning a plain text block, verified that the heading is on the first or second line.
Also tried other match patterns like:
$json.text.split(‘\n’).find(line => line.startsWith('## '))
Verified that the text field is populated in the node.
I want the file in Drive to be named like: “Recent News on Autonomous Agents_2025-07-30.txt”
and fallback to “WebSearch” if no heading is found.
Thank you all in advance.

