Platforms
Twitter

Twitter Integration

The Web Action SDK provides powerful actions to interact with Twitter. This guide covers all available Twitter actions, their inputs, outputs, and usage examples.

Actions

Send Message

Sends a message to a Twitter user.

Function: sdk.twitter.sendMessage
 
Input:
{
  recipient: string, // searches your messages for this recipient
  message: string
}
 
Output:
{
  message: string // success of action
}

Example:

const result = await sdk.twitter.sendMessage({
  recipient: "elonmusk",
  message: "Hello, how are you?",
});
 
console.log(result.message);

Get Profile Information

Retrieves the profile information for a Twitter user.

Function: sdk.twitter.getProfileInformation
 
Input:
{
  handle: string
}
 
Output:
{
  profile: {
    displayName: string,
    handle: string,
    profileUrl: string,
    bio: string,
    followersCount: number,
    followingCount: number,
    isFollowing: boolean
  }
}

Example:

const result = await sdk.twitter.getProfileInformation({
  handle: "elonmusk",
});
 
console.log(result.profile);

Follow Account

Follows a Twitter user.

Function: sdk.twitter.followAccount;
 
Input: {
  handle: string;
}
 
Output: {
  message: string; // success of action
}

Example:

const result = await sdk.twitter.followAccount({
  handle: "elonmusk",
});
 
console.log(result.message);

Search Twitter

Searches for tweets based on a query.

Function: sdk.twitter.searchTwitter
 
Input:
{
  query: string,
  topN: number, // 1-10, optional
  filter: string, // "Top" | "Latest" | "People" | "Media" | "Lists"
}
 
Output:
{
  results: Array<{
    displayName: string,
    handle: string,
    postUrl: string,
    tweetText: string,
    tweetDate: string
  }>
}

Example:

const result = await sdk.twitter.searchTwitter({
  query: "elon musk",
  topN: 5,
  filter: "Latest",
});
 
console.log(result.results);

Make Post

Makes a post on Twitter.

Function: sdk.twitter.makePost;
 
Input: {
  postContent: string;
}
 
Output: {
  message: string; // success of action
}

Example:

const result = await sdk.twitter.makePost({
  postContent: "Hello, how are you?",
});
 
console.log(result.message);

Like Post

Likes a post on Twitter.

Function: sdk.twitter.likePost
 
Input:
{
  postId: string,
  handle: string
}
 
Output:
{
  message: string // success of action
}

Example:

const result = await sdk.twitter.likePost({
  postId: "1234567890",
  handle: "elonmusk",
});
 
console.log(result.message);

Retweet Post

Retweets a post on Twitter.

Function: sdk.twitter.retweetPost
 
Input:
{
  postId: string,
  handle: string
}
 
Output:
{
  message: string // success of action
}

Example:

const result = await sdk.twitter.retweetPost({
  postId: "1234567890",
  handle: "elonmusk",
});
 
console.log(result.message);

Reply To Post

Replies to a post on Twitter.

Function: sdk.twitter.replyToPost
 
Input:
{
  postId: string,
  handle: string,
  message: string // 1-280 characters
}
 
Output:
{
  message: string // success of action
}

Example:

const result = await sdk.twitter.replyToPost({
  postId: "1234567890",
  handle: "elonmusk",
  message: "Hello, how are you?",
});
 
console.log(result.message);

Troubleshooting

If you encounter any issues while using the Twitter integration, please refer to our Troubleshooting Guide for common problems and their solutions.