Tutorial: DM Management, Export & Automation with Claude
You are my X/Twitter DM management specialist. I want to use XActions to send DMs, manage conversations, export message history, and set up automated responses. Help me take control of my inbox.
Context
I'm using XActions (https://github.com/nirholas/XActions), an open-source X/Twitter toolkit with DM capabilities via MCP tools (x_send_dm, x_get_conversations, x_export_dms) and browser console scripts (src/sendDirectMessage.js, src/automation/customerService.js).
What I Need You To Do
Part 1: DM Overview
First, help me understand my DM landscape:
Get my conversations using
x_get_conversations:"Show me my recent DM conversations"- List all active conversations
- Show unread count
- Identify important vs spam DMs
Export DM history using
x_export_dms:"Export my last 100 DM messages to JSON"- Full message history with timestamps
- Useful for backup or analysis
- Identify patterns in who DMs you
Part 2: Sending DMs
Send direct messages through Claude:
Single DM using
x_send_dm:"Send a DM to @username saying: Hey! Loved your thread about AI. Would love to connect!"Parameters:
username: Recipient (without @)message: Message text
DM templates for common scenarios:
Networking:
"Hey [name]! Really enjoyed your recent thread about [topic]. Your point about [specific insight] really resonated. Would love to continue the conversation — I'm working on [your project] which is in a similar space."
Collaboration:
"Hi [name]! I've been following your work on [their project] and think there could be some great synergy with what I'm building at [your project]. Would you be open to a quick chat about potential collaboration?"
Thank you:
"Hey [name], just wanted to say thanks for [specific action — retweeting, sharing, mentioning]. Really appreciate the support! 🙏"
Cold outreach:
"Hi [name]! I'm [your name], working on [brief description]. I came across your work through [how you found them] and was impressed by [specific thing]. I'd love to get your thoughts on [specific question]. No pressure — just admire your perspective."
DM etiquette tips:
- Always personalize — never send identical messages
- Reference something specific about them
- Keep it short (2-3 sentences max for first DM)
- Don't pitch immediately
- Don't ask for follows or retweets
Part 3: Browser Console DM Script
Walk me through src/sendDirectMessage.js:
How it works:
- Navigates to X DM interface
- Opens a new conversation or existing one
- Types and sends the message
- Uses X's DM selectors:
[data-testid="dmComposerTextInput"]for the text input[data-testid="dmComposerSendButton"]for send
Batch DM sending:
- Send personalized DMs to a list of users
- Important: Personalize each one (X flags identical mass DMs)
- Rate limit: 1-2 DMs per minute max
- Daily limit: Stay under 50 new DMs to avoid restrictions
Part 4: Customer Service Bot
For business accounts, set up src/automation/customerService.js:
Paste core.js, then configure customerService.js:
const CONFIG = { ACTIVE_ACCOUNT: 'your_business_account', MONITOR: { mentions: true, // Watch @mentions dms: true, // Watch DMs replies: true, // Watch replies to your posts keywords: true, // Watch brand keywords }, BRAND_KEYWORDS: ['your_brand', 'your_product'], RESPONSE: { autoReply: true, autoReplyDM: false, // Careful with auto DM replies requireApproval: true, // Review before sending (recommended!) markAsRead: true, }, BUSINESS_HOURS: { enabled: true, start: 9, // 9 AM end: 17, // 5 PM days: [1,2,3,4,5], // Mon-Fri outsideHoursMessage: "Thanks for reaching out! We're outside business hours (Mon-Fri 9-5 ET). We'll respond next business day! 🙏", }, CHECK_INTERVAL_SECONDS: 60, MAX_RESPONSES_PER_HOUR: 20, MAX_RESPONSES_PER_DAY: 100, };Response templates — the bot auto-categorizes messages:
const TEMPLATES = { greeting: ["Hi {customer}! Thanks for reaching out. How can I help? 😊"], issue: ["Hi {customer}, sorry about the trouble. Please DM us details so we can fix this."], thanks: ["Thank you {customer}! We really appreciate the kind words! ❤️"], question: ["Great question {customer}! Here's what I can tell you: [CUSTOMIZE]"], pricing: ["Hi {customer}! For pricing, check our website or DM us for a quote! 💰"], support: ["Hi {customer}! For support, DM us or email support@company.com 📧"], };Keyword auto-detection — Categorizes incoming messages:
- Issue keywords: problem, broken, doesn't work, refund, cancel
- Thanks keywords: thank, awesome, amazing, love, great
- Pricing keywords: price, cost, how much, discount
- Question keywords: ?, how do, what is, where, when
How it runs:
- Checks notifications every 60 seconds
- Detects new mentions/replies
- Auto-categorizes the message
- Picks appropriate template response
- If
requireApprovalis true, shows you the response before sending - Respects business hours
- Rate limits itself
Part 5: DM Export & Backup
Export your entire DM history:
Via MCP:
"Export all my DMs to JSON"Via browser script (
scripts/scrapeDMs.js):- Open X DM inbox
- Script scrolls through all conversations
- Extracts messages with timestamps, sender, and content
- Exports as JSON
Via CLI:
xactions dms --limit 500 --format json > my-dms-backup.jsonUse cases for DM exports:
- Backup important conversations
- Analyze common questions (for FAQ creation)
- Track business lead conversations
- Legal/compliance records
Part 6: DM Manager (Puppeteer)
For programmatic Node.js usage, the dmManager module:
import { dmManager } from 'xactions';
// Access DM management functions:
// - Send messages
// - Read conversations
// - Export conversations
// - Manage message requests
Walk me through the available functions and how to integrate them into custom scripts.
Part 7: DM Outreach Campaign
Help me set up a tasteful DM outreach campaign:
Define the campaign:
- Who am I reaching out to? (List of target usernames)
- What's the goal? (Networking, sales, collaboration, community building)
- What's the message? (Must be personalized per person)
Research each target using
x_get_profile:- What do they tweet about?
- What's in their bio?
- Any recent achievement I can reference?
Craft personalized messages — Give me a template but help me customize each one:
For @user1 (AI researcher): "Hey [name]! Your paper on [topic] was fascinating..." For @user2 (Startup founder): "Hi [name]! I saw your launch of [product]..." For @user3 (Community builder): "Hey [name]! Love what you're doing with [community]..."Send with appropriate pacing:
- 2-3 DMs per hour max
- Never more than 15-20 new DMs per day
- Wait for responses before sending to similar accounts
- Track who responded and who didn't
Follow-up strategy:
- If no response after 3-5 days, one gentle follow-up
- If still no response, move on
- Never send more than 2 messages without a reply
Part 8: DM Analytics
Track your DM performance:
- Response rate: What % of your outreach DMs get responses?
- Response time: How quickly do people reply?
- Conversion: How many DM conversations turned into real connections?
- Patterns: Which DM opener style works best?
My DM Goals
(Replace before pasting)
- Purpose: Networking / Customer service / Outreach / Backup
- Target users to DM: @user1, @user2 (or a description)
- Am I a business account? Yes/No
- Brand keywords to monitor: brand1, brand2
Start with Part 1 — show me my DM landscape and help me organize my inbox.
⚡ Explore XActions
100% free and open-source. No API keys, no fees, no signup.
Browse All Documentation