← Twitter Developer App

New Message from Twitter Developer App API

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

Trigger workflow on
New Message from the Twitter Developer App API
Next, do this
Connect to 600+ APIs using code and no-code building blocks
No credit card required
Trusted by 200,000+ developers from startups to Fortune 500 companies:
Trusted by 200,000+ developers from startups to Fortune 500 companies

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 + 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


This is a pre-built, open source 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


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

module.exports = {
  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.1",
  dedupe: "unique",
  hooks: {
    async deploy() {
      const accountId = await this.twitter_developer_app.getAccountId();
  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 {
        created_timestamp: ts,
        message_create: { message_data: { text = "" } },
      } = data;
      const maxTextLength = 16;
      const trimmedText = text.length > maxTextLength
        ? `${text.slice(0, maxTextLength)}...`
        : text;
      return {
        summary: trimmedText,
  async run() {
    const lastMessageId = this._getNextCursor();
    const directMessages = await this.twitter_developer_app.getNewDirectMessages({

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


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


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.
Twitter Developer Apptwitter_developer_appappThis component uses the Twitter Developer App app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between component invocations.


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.

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

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

About Pipedream

Stop writing boilerplate code, struggling with authentication and managing infrastructure. Start connecting APIs with code-level control when you need it — and no code when you don't.

Into to Pipedream
Watch us build a workflow
Watch us build a workflow
4 min
Watch now ➜
"The past few weeks, I truly feel like the clichéd 10x engineer."
Powerful features that scale
Manage concurrency and execution rate
Manage concurrency and execution rate

Queue up to 10,000 events per workfow and manage the concurrency and rate at which workflows are triggered.

Process large payloads up to 5 terabytes
Process large payloads up to 5 terabytes

Large file support enables you to trigger workflows with any data (e.g., large JSON files, images and videos) up to 5 terabytes.

Return custom responses to HTTP requests
Return custom responses to HTTP requests

Return any JSON-serializable response from an HTTP triggered workflow using $respond().

Use most npm packages
Use most npm packages

To use any npm package, just require() it -- there's no npm install or package.json required.

Maintain state between executions
Maintain state between executions

Use $checkpoint to save state in one workflow invocation and read it the next time your workflow runs.

Pass data between steps
Pass data between steps

Return data from any step to inspect it in a human-friendly way and reference the data in future steps via the steps object.