Skip to content

feat(scripts): add Mintlify assistant conversations export#2325

Open
johndmulhausen wants to merge 1 commit intomainfrom
conversation-downloader
Open

feat(scripts): add Mintlify assistant conversations export#2325
johndmulhausen wants to merge 1 commit intomainfrom
conversation-downloader

Conversation

@johndmulhausen
Copy link
Contributor

Summary

Adds scripts/download_mintlify_assistant_conversations.py to download AI assistant conversation history from the Mintlify Analytics API (GET /v1/analytics/{projectId}/assistant), following pagination until hasMore is false. Output is JSON with count and conversations.

Credentials

  • Read only from repo-root .env and .env.local (.env.local overrides duplicate keys).
  • Required: MINTLIFY_PROJECT_ID, MINTLIFY_API_KEY (organization admin key, usually mint_).

Implementation

  • Standard library only (urllib).
  • Cloudflare: browser-like User-Agent; on HTTP 403, retries via curl when available.
  • Strips a duplicated Bearer prefix, scrubs invisible Unicode from secrets, URL-encodes projectId in the path.
  • --verbose for debugging 401s; extra stderr hints when unauthorized.

Other

  • .gitignore: ignore .env so API keys are not committed.

How to test

python scripts/download_mintlify_assistant_conversations.py -o /tmp/conversations.json
python scripts/download_mintlify_assistant_conversations.py --verbose

This update includes the addition of the .env file to the .gitignore to prevent sensitive environment variables from being tracked in version control.
@johndmulhausen johndmulhausen marked this pull request as ready for review March 20, 2026 04:21
@johndmulhausen johndmulhausen requested a review from a team as a code owner March 20, 2026 04:21
Comment on lines +267 to +268
"Warning: Mintlify admin API keys normally start with mint_. "
f"If requests fail, create a key on {_DASHBOARD_API_KEYS}.",

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (password)
as clear text.

Copilot Autofix

AI 7 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

Comment on lines +310 to +318
"\n401 means Mintlify rejected the Bearer token for this project (not a transport bug).\n"
f" - Open {_DASHBOARD_API_KEYS}\n"
" - Create or rotate an organization admin API key (usually mint_...).\n"
" - Set MINTLIFY_PROJECT_ID to the Project ID shown on that page, not the docs "
"subdomain unless the dashboard explicitly says they are the same.\n"
" - Put only the raw secret in MINTLIFY_API_KEY (no 'Bearer ' prefix).\n"
" - Run again with --verbose to confirm URL, ID length, and key prefix.\n"
" - If it still fails, the key may lack Analytics API access for your plan; "
"contact Mintlify support with the time of the request.\n",

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.

Copilot Autofix

AI 7 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@github-actions
Copy link
Contributor

🔗 Link Checker Results

All links are valid!

No broken links were detected.

Checked against: https://wb-21fd5541-conversation-downloader.mintlify.app

@ngrayluna
Copy link
Contributor

I'm not sure exactly what this PR does. I created a simple shell script that got responses. 🤷

Script to get responses: https://github.com/ngrayluna/explore_mintlify_agent/blob/main/get_responses.sh
Then I convert the JSON into CSV: https://github.com/ngrayluna/explore_mintlify_agent/blob/main/json_to_csv.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants