Twitter/X Integration
Complete guide to automating Twitter/X with posting, likes, retweets, DMs, and search
Twitter/X Integration Guide
Complete guide for using Twitter/X automation steps in Loopi.
Overview
The Twitter integration allows you to automate interactions with Twitter/X, including:
- Creating, deleting, and searching tweets
- Liking and retweeting tweets
- Sending direct messages
- Searching for users
- Full variable support for dynamic content
Prerequisites
Twitter API Credentials
You need Twitter API v2 credentials to use these steps:
- API Key (Consumer Key)
- API Secret (Consumer Secret)
- Access Token
- Access Token Secret
Getting Credentials
- Go to Twitter Developer Portal
- Create a new app or use an existing one
- Navigate to "Keys and tokens"
- Generate/copy your credentials
- Ensure your app has the appropriate permissions (Read, Write, and Direct Messages)
Saving Credentials in Loopi
Recommended Method:
- Go to Settings → Credentials
- Click "Add Credential"
- Select type: Twitter/X
- Enter all four credentials
- Save with a descriptive name (e.g., "My Twitter Account")
- Use the saved credential in Twitter steps
Alternative: Enter credentials manually in each step (not recommended for security)
Step Types
1. Create Tweet
Post a new tweet to Twitter/X.
Fields:
- Tweet Text: Content of the tweet (max 280 characters)
- Authentication: Select saved credential or enter manually
- Reply to Tweet ID (optional): Tweet ID to reply to
- Quote Tweet ID (optional): Tweet ID to quote
- Media ID (optional): Media ID to attach
- Store Response in Variable (optional): Variable to store the response
Example Configuration:
{
"type": "twitterCreateTweet",
"text": "Hello from Loopi! #automation",
"credentialId": "my-twitter-credential",
"storeKey": "tweetData"
}With Variables:
{
"type": "twitterCreateTweet",
"text": "The price is now "`{{currentPrice}}`"! Check it out.",
"replyToTweetId": "{{targetTweetId}}",
"storeKey": "newTweet"
}Response Data: After creating a tweet, you can access:
{{tweetData.id}}- The tweet ID{{tweetData.text}}- The tweet text{{tweetData.created_at}}- Timestamp
2. Delete Tweet
Delete a tweet from your account.
Fields:
- Tweet ID: ID or URL of the tweet to delete
- Authentication: Select saved credential or enter manually
- Store Response in Variable (optional)
Example:
{
"type": "twitterDeleteTweet",
"tweetId": "1234567890123456789",
"credentialId": "my-twitter-credential"
}Tweet ID Formats:
- Direct ID:
1234567890123456789 - Full URL:
https://twitter.com/username/status/1234567890123456789 - X.com URL:
https://x.com/username/status/1234567890123456789 - Variable:
{{tweetId}}
3. Like Tweet
Like a tweet on Twitter/X.
Fields:
- Tweet ID: ID or URL of the tweet to like
- Authentication: Select saved credential
- Store Response in Variable (optional)
Example:
{
"type": "twitterLikeTweet",
"tweetId": "{{foundTweet.id}}",
"credentialId": "my-twitter-credential",
"storeKey": "likeResult"
}4. Retweet
Retweet a tweet to your timeline.
Fields:
- Tweet ID: ID or URL of the tweet to retweet
- Authentication: Select saved credential
- Store Response in Variable (optional)
Example:
{
"type": "twitterRetweet",
"tweetId": "https://twitter.com/user/status/123456789",
"credentialId": "my-twitter-credential",
"storeKey": "retweetResult"
}5. Search Tweets
Search for tweets using Twitter's search API (last 7 days for standard access).
Fields:
- Search Query: Search term or query with operators
- Max Results (optional): Number of results (1-100, default: 10)
- Start Time (optional): Filter tweets after this date
- End Time (optional): Filter tweets before this date
- Authentication: Select saved credential
- Store Results in Variable: Variable to store search results
Search Operators:
"exact phrase"- Search for exact phrase#hashtag- Search by hashtagfrom:username- Tweets from specific userto:username- Replies to specific user-word- Exclude tweets with wordword1 OR word2- Either wordword1 word2- Both words
Example:
{
"type": "twitterSearchTweets",
"query": "#automation OR #nocode",
"maxResults": "20",
"credentialId": "my-twitter-credential",
"storeKey": "searchResults"
}Accessing Results:
{{searchResults[0].id}} // First tweet ID
{{searchResults[0].text}} // First tweet text
{{searchResults[0].author_id}} // Author ID
{{searchResults[1].created_at}} // Second tweet timestamp6. Send Direct Message
Send a direct message to a Twitter user.
Fields:
- Recipient User ID: Twitter user ID to send message to
- Message Text: Content of the message
- Authentication: Select saved credential
- Store Response in Variable (optional)
Example:
{
"type": "twitterSendDM",
"recipientId": "123456789",
"text": "Thanks for your interest! Here's the info: {{productLink}}",
"credentialId": "my-twitter-credential",
"storeKey": "dmResult"
}Finding User IDs:
Use the "Search Users" step first, then access {{foundUsers[0].id}}
7. Search Users
Search for Twitter users by username or keywords.
Fields:
- Search Query: Username or keywords to search
- Max Results (optional): Number of results (1-100, default: 10)
- Authentication: Select saved credential
- Store Results in Variable: Variable to store search results
Example:
{
"type": "twitterSearchUsers",
"query": "automation",
"maxResults": "10",
"credentialId": "my-twitter-credential",
"storeKey": "users"
}Accessing Results:
{{users[0].id}} // User ID
{{users[0].username}} // Username (without @)
{{users[0].name}} // Display name
{{users[0].description}} // Bio
{{users[0].followers_count}} // Follower countExample Workflows
Workflow 1: Automated Tweet with Current Data
- API Call: Fetch current price from API → Store in
priceData - Set Variable: Extract price → Store in
currentPrice - Create Tweet: "Today's price:
{{currentPrice}}"
Workflow 2: Search and Retweet
- Search Tweets: Query
#automation→ Store intweets - Conditional: Check if
{{tweets[0].id}}exists - If yes: Retweet
{{tweets[0].id}} - If no: End automation
Workflow 3: Monitor and Reply
- Search Tweets: Query
to:yourusername→ Store inmentions - Set Variable: Get first mention →
firstMention = {{mentions[0]}} - Create Tweet: Reply to
{{firstMention.id}}with "Thanks for reaching out!"
Workflow 4: Automated DM Campaign
- Search Users: Query
automation enthusiasts→ Store inusers - Set Variable: Current user →
currentUser = {{users[0]}} - Send DM: To
{{currentUser.id}}with message - Wait: 5 seconds
- Conditional: Check if more users → Loop back to step 2
Workflow 5: Tweet + Screenshot
- Create Tweet: "Check out our latest update!" → Store in
newTweet - Navigate: Go to tweet URL
https://twitter.com/i/web/status/{{newTweet.id}} - Wait: 2 seconds
- Screenshot: Capture tweet
Rate Limits
Twitter API has rate limits. Standard access typically allows:
- Tweet creation: 200 per 15 minutes (user context)
- Search tweets: 180 per 15 minutes
- Like tweet: 1000 per 24 hours
- Retweet: 1000 per 24 hours
- Send DM: 500 per 24 hours
Best Practices:
- Add Wait steps between API calls (2-5 seconds)
- Use conditional logic to check for errors
- Store API responses to check for rate limit errors
- Monitor your automation's API usage
Error Handling
Common Errors:
- 401 Unauthorized: Invalid credentials
- 403 Forbidden: Insufficient permissions or suspended account
- 404 Not Found: Tweet or user doesn't exist
- 429 Too Many Requests: Rate limit exceeded
- 400 Bad Request: Invalid input (e.g., text too long)
Handling Errors:
- Store API responses in variables
- Add conditional checks for success/failure
- Use try-catch patterns with conditional nodes
- Add meaningful log messages
Tips & Best Practices
- Use Credentials Manager: Store Twitter credentials securely
- Test with small limits: Use
maxResults: "5"when testing - Respect rate limits: Add delays between API calls
- Handle errors gracefully: Check for empty results before accessing
- Use variables: Make tweets dynamic with
{{variables}} - Store responses: Keep tweet IDs for follow-up actions
- Follow Twitter rules: Respect automation policies and terms of service
- Monitor activity: Review automation logs regularly
- Be respectful: Don't spam or harass users
- Test thoroughly: Run automations manually before scheduling
Permissions Required
Ensure your Twitter app has these permissions:
- ✅ Read - For searching tweets/users
- ✅ Write - For creating/deleting tweets, liking, retweeting
- ✅ Direct Messages - For sending DMs
To update permissions:
- Go to Twitter Developer Portal → Your App → Settings
- Edit App permissions
- Select appropriate level
- Regenerate access token and secret (existing tokens keep old permissions)
- Update credentials in Loopi
Related Documentation
- Credentials Management - Learn how to store Twitter credentials
- Variables Guide - Understanding variable access
- API Reference - All step types reference
- Examples - Ready-made Twitter automation examples