Send messages to AI chatbots (Gemini, ChatGPT) via Playwright browser automation and return responses with citations.
| Chatbot | Script | Website |
|---|---|---|
| --------- | -------- | --------- |
| Google Gemini | scripts/ask_gemini.py | gemini.google.com |
| ChatGPT | scripts/ask_chatgpt.py | chatgpt.com |
If the script fails to connect (Chrome not running or no --remote-debugging-port), start Chrome:
{baseDir}/scripts/start_chrome.sh
The start script has built-in locking and CDP detection to handle concurrent starts safely. It launches Chrome with --remote-debugging-port=9222 and --user-data-dir=~/.openclaw/workspace/chrome_profile. Login sessions persist across restarts.
Choose chatbot: Use the one the user names ("ask Gemini", "用 ChatGPT 查"). "GPT" means ChatGPT. Default to Gemini if unspecified.
Extract query: Strip only the trigger prefix. Do NOT rephrase, translate, summarize, or add context. Pass the rest verbatim:
| User says | Extracted query |
|---|---|
| ----------- | ---------------- |
| "ask Gemini what is MCP protocol" | "what is MCP protocol" |
| "问一下 ChatGPT,transformer 的注意力机制怎么工作" | "transformer 的注意力机制怎么工作" |
| "用 GPT 查一下 React 19 有什么新特性" | "React 19 有什么新特性" |
# Gemini
{baseDir}/.venv/bin/python3 {baseDir}/scripts/ask_gemini.py "extracted query"
# ChatGPT
{baseDir}/.venv/bin/python3 {baseDir}/scripts/ask_chatgpt.py "extracted query"
| Flag | Description | Default |
|---|---|---|
| ------ | ------------- | --------- |
--port PORT | Chrome CDP port | 9222 |
--timeout SECS | Max wait for response | 120 |
--new-chat | Force new chat session | false |
--json | JSON output | false |
Return the script output to the user VERBATIM. Do NOT summarize, rephrase, translate, or otherwise alter the response. Present the full, unmodified text exactly as the script printed it.
| Error | Action |
|---|---|
| ------- | -------- |
| "Cannot connect to Chrome on port 9222" | Run {baseDir}/scripts/start_chrome.sh (has built-in lock and CDP check), wait 5 seconds, retry. Do NOT kill Chrome manually. |
| "You are not logged in" | Inform user to log in manually in the Chrome window |
| "Could not find input field" | Selectors may be outdated; inform user the script may need updating |
| Response timeout | Retry with --timeout 300 |
cd {baseDir} && rm -rf .venv && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
共 1 个版本