x-dm-auto-chat
The x-dm-auto-chat Skill automates X (Twitter) direct messaging by scanning the DM inbox to identify conversations awaiting replies, reading message history, generating persona-based responses, and sending messages. It also supports searching for users and initiating new conversations. Use this Skill when you need to handle unread DMs automatically, conduct batch outreach campaigns, process pending replies with a consistent persona, or run an automated Twitter DM bot that follows your specified tone and communication style.
git clone --depth 1 https://github.com/browser-act/skills /tmp/x-dm-auto-chat && cp -r /tmp/x-dm-auto-chat/solutions/social-listening/x-dm-auto-chat ~/.claude/skills/x-dm-auto-chatSKILL.md
# X (Twitter) — DM Auto Chat (End-to-End)
> Full X DM automation Skill: inbox scan → conversation read → persona-based reply → send; also supports search-and-outreach. The calling Agent generates reply text based on persona; this Skill handles all mechanical operations.
## Language
All process output to user (progress updates, process notifications) follows the user's language.
## Objective
Encapsulate "refresh DM list → identify pending replies → read context → reply with persona → send" and "search user → enter chat → send first message" into callable end-to-end capabilities.
## Prerequisites
- Browser is open at X site, logged into X account (`[aria-label="Account menu"]` present)
- The 4-digit DM passcode for the current account is available (required for E2E encryption)
- Caller has prepared a "persona description" (used to generate replies), e.g.:
- `"You are BrowserAct outreach team. Tone: friendly, concise, professional. Goal: invite creators to collaborate."`
- Optional: list of target user search queries (for outreach scenario)
## Pre-execution Checks
### 1. Tool Readiness
If browser-act has been confirmed available in the current session → skip.
Invoke `browser-act` via Skill tool to load usage. If installation or configuration issues arise, follow its guidance to resolve then retry.
### 2. Open DM Entry + Comprehensive State Check
```
browser-act --session <name> navigate https://x.com/i/chat
browser-act --session <name> wait stable --timeout 15000
browser-act --session <name> eval "$(python scripts/check-page-state.py)"
```
Return format:
```json
{
"url": "https://x.com/i/chat/pin/recovery?from=%2Fi%2Fchat",
"logged_in": true,
"need_passcode": true,
"on_inbox": false,
"on_conversation": false,
"has_panel": false,
"has_composer": false,
"inbox_count": 0
}
```
Decision matrix:
- `logged_in: false` → inform user to log in first; wait; retry this step
- `need_passcode: true` → proceed to step 3 below
- `on_inbox: true` and `inbox_count > 0` → ready, enter business flow
- `on_inbox: true` but `inbox_count === 0` → account has no DM conversations; outreach scenario can still proceed, pending-reply scenario has nothing to do
### 3. DM Passcode Unlock (when need_passcode is true)
1. If caller has provided passcode in advance → use it directly; otherwise ask user for 4-digit DM passcode via **AskUserQuestion tool** (do not use plain text prompt — must call AskUserQuestion)
2. `browser-act --session <name> state` — find indexes of 4 `<input maxlength=1 pattern=[0-9]*>` elements (usually 4 consecutive)
3. Enter each digit: `browser-act --session <name> input <idx1> "<d1>"`, `<idx2> "<d2>"`, `<idx3> "<d3>"`, `<idx4> "<d4>"`
- **Must use `browser-act input` (CDP real keyboard events), cannot use eval to set value** — X ignores non-real keyboard input
4. `browser-act --session <name> wait stable --timeout 10000`
5. Re-run `check-page-state.py`, confirm `need_passcode: false` and `on_inbox: true`
6. 3 consecutive failures still showing `need_passcode: true` → inform user passcode may be wrong; terminate
## Business Flows
> Choose Scenario A, Scenario B, or both. Each scenario is an ordered AI Workflow (not a single JS).
### Scenario A: Scan unread DMs → Persona-based reply
**Flow**: `Scan inbox → Filter unread & latest peer messages → Per-conversation: read context → Generate reply with persona → Send → Next`
**Steps**:
1. **Scan inbox**:
```
browser-act --session <name> eval "$(python scripts/scan-inbox-merged.py)"
```
Returns `items[]`, each containing `conversation_id` / `conversation_url` / `peer_screen_name` / `peer_display_name` / `peer_can_dm` / `latest_message_preview` / `latest_message_from_self` / `unread`, etc.
2. **Filter pending-reply conversations**: from `items`, select conversations meeting all conditions:
- `unread === true` (has unread) **or** `latest_message_from_self === false` (peer's latest message not yet replied)
- `peer_can_dm === true` (recipient allows DM)
- `is_muted !== true` and `is_deleted_by_viewer !== true`
- Optional caller filters: only reply to specific screen_names, exclude already-replied (use external JSONL ledger)
3. **For each pending-reply conversation** (strictly serial, **random `sleep 8-15` seconds between each**):
a. **Open conversation**:
```
browser-act --session <name> navigate https://x.com<conversation_url>
browser-act --session <name> wait stable --timeout 15000
```
b. **If passcode re-triggered** → re-unlock (usually won't re-trigger within same session)
c. **Read context**:
```
browser-act --session <name> eval "$(python scripts/read-conversation.py)"
```
Returns `messages[]`, each with `direction` (self/peer), `text`, `timestamp_text`, `links`, `images`.
d. **(Optional) Load full history**: If caller needs longer context, loop:
```
browser-act --session <name> eval "$(python scripts/scroll-load-history.py)"
```
Until `reached_top: true`, then re-read with `read-conversation.py`.
e. **Generate reply**: **Calling Agent combines persona, message history to generate reply text.** Reply content is entirely the caller's decision; this Skill does not participate in generation. Suggested inputs:
- Persona prompt (provided by caller)
- Recent N messages (typically `messages.slice(-6)`)
- Peer name (`peer_display_name` / `peer_screen_name`) for address
- Return one string `reply_text`, length < 10,000 characters
f. **Send reply**:
1. `browser-act --session <name> eval "$(python scripts/check-composer.py)"` → record `last_message_id`
2. `browser-act --session <name> state` — find `<textarea placeholder=Message>` index `TA_IDX`
3. `browser-act --session <name> input <TA_IDX> "<reply_text>"` (**must use CDP real keyboard, cannot use eval**)
4. `browser-act --session <name> wait --selector '[data-testid="dm-composer-send-button"]' --stateExtracts comprehensive wholesale product data from 1688.com product detail pages: title, tiered pricing, SKU variants with dimensions/weight, product images, seller info, shop scores, buyer protection, cross-border flags, product attributes, coupon/promotion data, and review stats. Use when user mentions 1688, 1688.com, wholesale China, alibaba wholesale, B2B China sourcing, Chinese wholesale scraper, 1688 product scrape, 1688 offer, 1688 detail, extract 1688 data, pull 1688 listings, get wholesale price, 1688 supplier info, factory stats 1688, 1688 SKU variants, 1688 product attributes, 1688 shop score, DSR score 1688, 1688 buyer protection, 1688 cross-border, 1688 dropship. Also applies to: scraping bulk product data from 1688 by offer ID list, monitoring 1688 supplier metrics, extracting 1688 pricing tiers for resale analysis.
Fetches complete Airbnb listing details for a given numeric listing ID via the internal GraphQL API, returning title, room type, description, amenities, photos, coordinates, city, house rules, highlights, ratings, review count, bedroom configuration, and property overview. Use when user mentions Airbnb listing details, Airbnb property info, Airbnb room details, get Airbnb listing data, Airbnb amenities list, Airbnb house rules, Airbnb property description, Airbnb detail page scraper, Airbnb rooms detail, Airbnb property page data, Airbnb listing info, fetch Airbnb room details, pull Airbnb listing.
Extracts Airbnb accommodation search results from a destination query via SSR-embedded data, returning listing ID, URL, name, coordinates, rating, price, photos, and badge info for each result, plus pagination cursors for multi-page retrieval. Use when user mentions Airbnb search results, Airbnb listings, vacation rental search, short-term rental listings, scrape Airbnb, get Airbnb data, find rentals on Airbnb, Airbnb destination search, Airbnb property list, Airbnb stays search, Airbnb accommodation results, pull Airbnb listings, collect Airbnb search data, Airbnb scraper, Airbnb search page extraction, Airbnb search by destination.
Amazon Alexa for Shopping Q&A automation: submits questions to Amazon's Alexa/Rufus AI shopping assistant and collects response text; supports optional keyword search context (navigate to search results page before asking for category-specific answers). Use when user mentions Amazon Alexa, Rufus, Amazon shopping assistant, Amazon AI chat, ask Amazon, Amazon Q&A, automate Alexa questions, Rufus chatbot, Amazon assistant automation, collect Alexa responses, bulk question submission to Amazon, keyword search context, category research. Also applies to extracting Amazon product recommendations from conversational AI, automating repeated queries to Amazon's AI shopping feature, collecting Alexa shopping responses at scale, or market research within a specific product category.
This skill helps users extract structured product details from Amazon using a specific ASIN (Amazon Standard Identification Number). Use this skill when the user asks to get Amazon product details by ASIN, lookup Amazon product title and price using ASIN, extract Amazon product ratings and reviews count for a specific ASIN, check Amazon product availability and current price, get Amazon product description and features via ASIN, enrich product catalog with Amazon data using ASIN, monitor Amazon product price changes for specific ASINs, retrieve Amazon product brand and material information, fetch Amazon product images and specifications by ASIN, validate Amazon ASIN and get product metadata.
This skill helps users extract structured best-selling product data from Amazon via the BrowserAct API. Agent should proactively apply this skill when users express needs like search for best selling products on Amazon, extract Amazon product data based on keywords, find top rated Amazon products, monitor Amazon competitor prices and sales, discover trending products on Amazon marketplace, extract Amazon product titles prices and ratings, gather Amazon product sales volume for market research, search Amazon best sellers in specific region, collect Amazon product reviews and promotion details, analyze Amazon product availability and badges, get Amazon product data for market analysis.
Amazon Best Sellers listing scraper: extract product cards from any Amazon Best Sellers (zgbs) or /gp/bestsellers/ category page — returns rank (position on chart), asin, title, url, image, imageAlt, price, stars, reviewCount, ratingRaw per item, plus category metadata (categoryName, categoryFullName, categoryUrl) and pagination state (currentPage, hasNextPage, nextPageUrl). Works across all Amazon regional TLDs (amazon.com, amazon.co.uk, amazon.de, amazon.co.jp, amazon.fr, amazon.it, amazon.es, amazon.ca, amazon.com.au, amazon.in, etc.). Use when user mentions Amazon Best Sellers, Amazon bestsellers, Amazon top 100, Amazon zgbs, Amazon /zgbs/, Amazon /gp/bestsellers/, Amazon Best Sellers Rank, Amazon BSR, Amazon top ranked products, Amazon top-selling products, Amazon chart, Amazon category ranking, Amazon best sellers by category, Amazon best sellers electronics, Amazon best sellers kitchen, Amazon best sellers toys, scrape Amazon bestsellers, extract Amazon top 100, Amazon rank scraper, Amazon best seller list, Amazon leaderboard, Amazon trending products, discover trending Amazon products, Amazon niche discovery, Amazon top ranked ASINs. Also applies to competitive intelligence via ranking snapshots, spotting up-and-coming products, sourcing bestseller ASINs for further enrichment, tracking rank changes over time, and building bestseller-per-category datasets.
This skill helps users extract basic product details other sellers prices and seller ratings from Amazon via ASIN automatically using the BrowserAct API. Agent should proactively apply this skill when users express needs like query Amazon buy box information, monitor Amazon product prices, extract Amazon product details by ASIN, check other sellers prices on Amazon, get Amazon seller ratings and feedback count, monitor buy box ownership for a specific ASIN, track Amazon fulfillment methods for competitors, compare Amazon product prices across different sellers, retrieve Amazon buy box availability status, analyze Amazon seller profile details.