Manipulating Threads (threads.net) with the OpenClaw browser tool.
Prerequisites
Environment Requirements
- OpenClaw with browser tool enabled
openclawbrowser profile- Threads account login completed
If it's a headless server (no GUI)
Xvfb virtual display required:
# 1. Xvfb 설치 및 서비스 등록
sudo apt install -y xvfb
sudo tee /etc/systemd/system/xvfb.service << 'EOF'
[Unit]
Description=X Virtual Frame Buffer
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/Xvfb :99 -screen 0 1920x1080x24
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now xvfb
# 2. OpenClaw Gateway에 DISPLAY 환경변수 추가
mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d
echo -e '[Service]\nEnvironment=DISPLAY=:99' > ~/.config/systemd/user/openclaw-gateway.service.d/display.conf
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway
Login (only once at first)
browser action=start profile=openclaw
browser action=open profile=openclaw targetUrl="https://www.threads.net/login"
# 사용자에게 수동 로그인 요청
Usage
1. Reading the timeline
browser action=open profile=openclaw targetUrl="https://www.threads.net"
browser action=snapshot profile=openclaw compact=true
In the results, you can check each post's author, content, and like/comment counts.
2. Posting (full flow)
Step 1: Go to home
browser action=open profile=openclaw targetUrl="https://www.threads.net"
browser action=snapshot profile=openclaw compact=true
Step 2: Find and click the "What's new?" button
In the snapshot, "What's new?" or "Empty text field" find the ref of the button containing
browser action=act profile=openclaw request={"kind":"click","ref":"e14"}
(the ref differs for each snapshot! Always check in the snapshot)
Step 3: Enter text in the dialog
browser action=snapshot profile=openclaw compact=true
textbox find the ref and:
browser action=act profile=openclaw request={"kind":"type","ref":"e14","text":"포스팅 내용"}
Step 4: Click the Post button
browser action=act profile=openclaw request={"kind":"click","ref":"e22"}
(also check the Post button ref in the snapshot)
Step 5: Confirm
browser action=snapshot profile=openclaw compact=true
→ If you see the "Posted" text and the "View" link, it's a success!
3. Viewing a profile
browser action=open profile=openclaw targetUrl="https://www.threads.net/@username"
browser action=snapshot profile=openclaw compact=true
4. Search
browser action=open profile=openclaw targetUrl="https://www.threads.net/search?q=검색어"
browser action=snapshot profile=openclaw compact=true
5. Replying
# 게시물 열기
browser action=open profile=openclaw targetUrl="https://www.threads.net/@user/post/POSTID"
browser action=snapshot profile=openclaw compact=true
# Reply 버튼 클릭 (ref 확인 후)
browser action=act profile=openclaw request={"kind":"click","ref":"<reply-ref>"}
# 텍스트 입력 및 게시 (포스팅과 동일)
Key Points
- Snapshot first! - Before every task, check the current page state and refs with a snapshot
- The ref changes every time - Always find it anew in the snapshot results
- compact=true - Always use it to save tokens
- Keep targetId - To work in the same tab, use the targetId parameter
- Confirm before posting - Get confirmation of the content from the user before posting
Troubleshooting
| Problem | Solution |
|---|---|
| browser tool not working | Check that Xvfb is running, check that DISPLAY=:99 is set, restart the Gateway |
| Not logged in | /login Go to the page and request manual login |
| Can't find ref | Take the snapshot again and look for similar text/buttons |
| Posting not working | Check whether the Post button is disabled (text input required) |