← Twitter Developer App

New Message from Twitter Developer App API

Pipedream makes it easy to connect APIs for Twitter Developer App and 1200+ other apps remarkably fast.

Trigger workflow on
New Message from the Twitter Developer App API
Next, do this
Connect to 1200+ APIs using code and no-code building blocks
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 500,000+ developers from startups to Fortune 500 companies

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

Trigger a workflow on New Message with Twitter Developer App API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the New Message trigger
    1. Connect your Twitter Developer App account
    2. Configure timer
  2. Add steps to connect to 1200+ APIs using code and no-code building blocks
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Send Message with Discord Webhook API on New Message from Twitter Developer App API
Twitter Developer App + Discord Webhook
 
Try it
Add Multiple Rows with Google Sheets API on New Message from Twitter Developer App API
Twitter Developer App + Google Sheets
 
Try it
Get Film with SWAPI - Star Wars API on New Message from Twitter Developer App API
Twitter Developer App + SWAPI - Star Wars
 
Try it
Create Multiple Records with Airtable API on New Message from Twitter Developer App API
Twitter Developer App + Airtable
 
Try it
Chat with OpenAI (ChatGPT) API on New Message from Twitter Developer App API
Twitter Developer App + OpenAI (ChatGPT)
 
Try it

Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

New Message on Twitter Developer App
Description:Emit new event each time the authenticated user receives a Direct Message
Version:0.0.2
Key:twitter_developer_app-new-message

Code

const common = require("../common");

module.exports = {
  ...common,
  type: "source",
  key: "twitter_developer_app-new-message",
  name: "New Message",
  description: "Emit new event each time the authenticated user receives a Direct Message",
  version: "0.0.2",
  dedupe: "unique",
  hooks: {
    async deploy() {
      const accountId = await this.twitter_developer_app.getAccountId();
      this._setAccountId(accountId);
    },
  },
  methods: {
    _getAccountId() {
      return this.db.get("accountId");
    },
    _setAccountId(accountId) {
      this.db.set("accountId", accountId);
    },
    _getNextCursor() {
      return this.db.get("nextCursor");
    },
    _setNextCursor(nextCursor) {
      this.db.set("nextCursor", nextCursor);
    },
    _isRelevant(directMessage) {
      return (
        directMessage.type === "message_create" &&
        directMessage.message_create &&
        directMessage.message_create.sender_id != this._getAccountId()
      );
    },
    _processEvent(directMessage) {
      const meta = this.generateMeta(directMessage);
      this.$emit(directMessage, meta);
    },
    generateMeta(data) {
      const {
        id,
        created_timestamp: ts,
        message_create: { message_data: { text = "" } },
      } = data;
      const maxTextLength = 16;
      const trimmedText = text.length > maxTextLength
        ? `${text.slice(0, maxTextLength)}...`
        : text;
      return {
        id,
        summary: trimmedText,
        ts,
      };
    },
  },
  async run() {
    const lastMessageId = this._getNextCursor();
    const directMessages = await this.twitter_developer_app.getNewDirectMessages({
      lastMessageId,
    });

    const receivedDirectMessages = directMessages.filter(this._isRelevant.bind(this));
    if (receivedDirectMessages.length === 0) {
      console.log("No new direct messages detected. Skipping...");
      return;
    }

    receivedDirectMessages
      .reverse()
      .forEach(this._processEvent.bind(this));

    const { id: maxMessageId } = receivedDirectMessages.pop();
    this._setNextCursor(maxMessageId);
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Twitter Developer Apptwitter_developer_appappThis component uses the Twitter Developer App app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer

Authentication

Twitter Developer App uses API keys for authentication. When you connect your Twitter Developer App account, Pipedream securely stores the keys so you can easily authenticate to Twitter Developer App APIs in both code and no-code steps.

Video Tutorial on how to create and connect a Twitter Developer App to Pipedream

First, you'll need to sign up for a Twitter developer account and create a new application in the Twitter app dashboard.

  1. Register a new app on https://developers.twitter.com
  2. Apply for a new Twitter app, be detailed about your use
  3. After approval, create a new Standalone App
  4. Copy the api_key and api_secret_key into a Twitter Developer App Account on Pipedream
  5. Generate a new set of keys for your specific Twitter account
  6. Paste the access_token and access_token_secret in the Twitter Developer App Account on Pipedream

Once you've created an app, visit the Keys and tokens section of the app's settings, and add the API key, API secret key, Access token, and Access token secret below.

About Twitter Developer App

Use a Twitter developer app you've created to send API requests

More Ways to Use Twitter Developer App

Triggers

New Tweet Metrics from the Twitter Developer App API
 
Try it
New Message from the Twitter Developer App API

Emit an event each time the authenticated user receives a Direct Message

 
Try it
New Tweet Metrics from the Twitter Developer App API

Emit new event on each new twitter metric

 
Try it

Actions

Send Direct Message (DM) with the Twitter Developer App API

Send a DM to a user.

 
Try it

Explore Other Apps

1
-
12
of
1200+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Beta
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Beta
Data Stores
Data Stores
Use Pipedream Data Stores to manage state throughout your workflows.
Telegram Bot
Telegram Bot
Telegram is a cloud-based instant messaging and voice over IP service
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular apps like ChatGPT and DALL·E 2.
Google Sheets
Google Sheets
With Google Sheets, you can create, edit, and collaborate wherever you are
Discord
Discord
Use this app to create a Discord source that emits messages from your guild to a Pipedream workflow.
GitHub
GitHub
Where the world builds software. Millions of developers and companies build, ship, and maintain their software on GitHub—the largest and most advanced development platform in the world.
Formatting
Formatting
Pre-built actions to make formatting and manipulating data within your workflows easier.
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.