Skip to main content
Pipedream is useful when you want a webhook trigger plus small JavaScript or Python code steps for cleanup, dedupe, and routing.

Prerequisites

  • A Twexapi API key
  • A Pipedream HTTP trigger
  • An MCP-capable agent connected to https://api.twexapi.io/mcp
  • Optional connected accounts for Slack, Sheets, Airtable, or a database

Webhook-first flow

  1. Create an HTTP / Webhook trigger in Pipedream.
  2. Ask an MCP-capable agent to collect Twexapi rows.
  3. POST strict JSON to the Pipedream endpoint.
  4. Use a code step to normalize and dedupe rows.

JavaScript normalization step

export default defineComponent({
  async run({ steps }) {
    const payload = steps.trigger.event.body;

    return payload.tweets.map((tweet) => ({
      id: tweet.tweet_id,
      url: tweet.public_url ?? `https://x.com/i/web/status/${tweet.tweet_id}`,
      author: tweet.author_username,
      text: tweet.text,
      created_at: tweet.created_at,
      route_used: payload.route_used,
      next_cursor: payload.next_cursor,
    }));
  },
});

Agent prompt

Use Twexapi MCP to get quote tweets for tweet ID 1803006263529541838.
Return only JSON with route_used, source_tweet_id, has_more, next_cursor, and tweets.
Each tweet must include tweet_id, author_username, text, created_at, and public_url.

Direct REST step

Use a Pipedream code step when the workflow should continue through REST after the initial MCP handoff.
export default defineComponent({
  async run({ steps, $ }) {
    const response = await fetch("https://api.twexapi.io/twitter/advanced_search", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.TWEXAPI_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        searchTerms: ["AI agents lang:en"],
        maxItems: 20,
        sortBy: "Latest",
      }),
    });

    if (!response.ok) {
      throw new Error(`Twexapi request failed with HTTP ${response.status}`);
    }

    return response.json();
  },
});

Testing checklist

  • Confirm the trigger body is valid JSON.
  • Use tweet_id or user_id as the dedupe key.
  • Store next_cursor in Pipedream data stores for scheduled continuation.
  • Keep TWEXAPI_API_KEY in Pipedream environment variables.