Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.9 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { xquikAuth } from '../auth';
import { xquikCommon } from '../common';

export const getUserTweets = createAction({
  auth: xquikAuth,
  name: 'get_user_tweets',
  classification: 'SEARCH',
  displayName: 'Get User Tweets',
  description: 'List recent posts from a public X/Twitter user',
  audience: 'both',
  aiMetadata: {
    description:
      "Lists a public X/Twitter user's recent timeline posts, identified by username (with or without the @) or numeric user ID. Use to read an account's activity; replies and parent-post context can optionally be included. Read-only and idempotent.",
    idempotent: true,
  },
  props: {
    user: Property.ShortText({
      displayName: 'User',
      description: 'Username with or without @, or a numeric user ID.',
      required: true,
    }),
    cursor: Property.ShortText({
      displayName: 'Cursor',
      description: 'Pagination cursor from a previous response.',
      required: false,
    }),
    includeReplies: Property.Checkbox({
      displayName: 'Include Replies',
      description: 'Include reply posts in the timeline response.',
      required: false,
      defaultValue: false,
    }),
    includeParentTweet: Property.Checkbox({
      displayName: 'Include Parent Tweet',
      description: 'Include parent post context when available.',
      required: false,
      defaultValue: false,
    }),
  },
  async run(context) {
    const user = xquikCommon.utils.stripAtPrefix(context.propsValue.user);

    return xquikCommon.api.get({
      apiKey: context.auth.secret_text,
      path: `/x/users/${xquikCommon.utils.encodePathPart(user)}/tweets`,
      queryParams: xquikCommon.utils.cleanQueryParams({
        cursor: context.propsValue.cursor,
        includeParentTweet: context.propsValue.includeParentTweet,
        includeReplies: context.propsValue.includeReplies,
      }),
    });
  },
});