← HTTP / Webhook + Twitter Developer App integrations

Send Direct Message (DM) with Twitter Developer App API on New Requests from HTTP / Webhook API

Pipedream makes it easy to connect APIs for Twitter Developer App, HTTP / Webhook and 1000+ other apps remarkably fast.

Trigger workflow on
New Requests from the HTTP / Webhook API
Next, do this
Send Direct Message (DM) with the Twitter Developer App API
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

This integration creates a workflow with a HTTP / Webhook trigger and Twitter Developer App action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Requests trigger
    1. Optional- Configure Body Only
    2. Optional- Configure Response Status Code
    3. Optional- Configure Response Content-Type
    4. Optional- Configure Response Body
    5. Connect your HTTP / Webhook account
  3. Configure the Send Direct Message (DM) action
    1. Connect your Twitter Developer App account
    2. Configure Recipient ID
    3. Configure message
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are 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.

Trigger

Description:Get a URL and emit the full HTTP event on every request (including headers and query parameters). You can also configure the HTTP response code, body, and more.
Version:0.1.1
Key:http-new-requests

Trigger Code

import http from "../../http.app.mjs";

// Core HTTP component
export default {
  key: "http-new-requests",
  name: "New Requests",
  description: "Get a URL and emit the full HTTP event on every request (including headers and query parameters). You can also configure the HTTP response code, body, and more.",
  version: "0.1.1",
  type: "source",
  props: {
    httpInterface: {
      type: "$.interface.http",
      customResponse: true,
    },
    emitBodyOnly: {
      type: "boolean",
      label: "Body Only",
      description: "This source emits an event representing the full HTTP request by default. Select `true` to emit the body only.",
      optional: true,
      default: false,
    },
    resStatusCode: {
      type: "string",
      label: "Response Status Code",
      description: "The status code to return in the HTTP response",
      optional: true,
      default: "200",
    },
    resContentType: {
      type: "string",
      label: "Response Content-Type",
      description: "The `Content-Type` of the body returned in the HTTP response",
      optional: true,
      default: "application/json",
    },
    resBody: {
      type: "string",
      label: "Response Body",
      description: "The body to return in the HTTP response",
      optional: true,
      default: "{ \"success\": true }",
    },
    http,
  },
  async run(event) {
    const summary = `${event.method} ${event.path}`;

    this.httpInterface.respond({
      status: this.resStatusCode,
      body: this.resBody,
      headers: {
        "content-type": this.resContentType,
      },
    });

    if (this.emitBodyOnly) {
      this.$emit(event.body, {
        summary,
      });
    } else {
      this.$emit(event, {
        summary,
      });
    }
  },
};

Trigger 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
N/AhttpInterface$.interface.httpThis component uses $.interface.http to generate a unique URL when the component is first instantiated. Each request to the URL will trigger the run() method of the component.
Body OnlyemitBodyOnlyboolean

This source emits an event representing the full HTTP request by default. Select true to emit the body only.

Response Status CoderesStatusCodestring

The status code to return in the HTTP response

Response Content-TyperesContentTypestring

The Content-Type of the body returned in the HTTP response

Response BodyresBodystring

The body to return in the HTTP response

HTTP / WebhookhttpappThis component uses the HTTP / Webhook app.

Trigger Authentication

The HTTP / Webhook API does not require authentication.

About HTTP / Webhook

Get a unique URL where you can send HTTP or webhook requests

Action

Description:Send a DM to a user.
Version:0.0.3
Key:twitter_developer_app-send-dm

Action Code

const twitter = require("../../twitter_developer_app.app.js");
const Twit = require("twit");

module.exports = {
  key: "twitter_developer_app-send-dm",
  name: "Send Direct Message (DM)",
  description: "Send a DM to a user.",
  version: "0.0.3",
  type: "action",
  props: {
    twitter,
    recipient_id: {
      type: "string",
      label: "Recipient ID",
      description: "The ID of the user who should receive the direct message. You must pass the string value of the numeric id (i.e, the value for the `id_str` field in Twitter's `user` object). For example, the correct ID to send a DM to `@pipedream` is `1067926271856766976`. If you only have the user's screen name, lookup the user first and pass the `id_str` to this field.",
    },
    message: {
      type: "string",
      description: "The text of your direct message. Max length of 10,000 characters. Max length of 9,990 characters if used as a [Welcome Message](https://developer.twitter.com/en/docs/direct-messages/welcome-messages/api-reference/new-welcome-message).",
    },
  },
  async run() {
    const {
      api_key, api_secret_key, access_token, access_token_secret,
    } = this.twitter.$auth;

    const T = new Twit({
      consumer_key: api_key,
      consumer_secret: api_secret_key,
      access_token,
      access_token_secret,
      timeout_ms: 60 * 1000,  // optional HTTP request timeout to apply to all requests.
      strictSSL: true,  // optional - requires SSL certificates to be valid.
    });

    const response = await T.post("direct_messages/events/new", {
      "event": {
        "type": "message_create",
        "message_create": {
          "target": {
            "recipient_id": this.recipient_id,
          },
          "message_data": {
            "text": this.message,
          },
        },
      },
    });

    return response.data.event;
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
Twitter Developer ApptwitterappThis component uses the Twitter Developer App app.
Recipient IDrecipient_idstring

The ID of the user who should receive the direct message. You must pass the string value of the numeric id (i.e, the value for the id_str field in Twitter's user object). For example, the correct ID to send a DM to @pipedream is 1067926271856766976. If you only have the user's screen name, lookup the user first and pass the id_str to this field.

messagemessagestring

The text of your direct message. Max length of 10,000 characters. Max length of 9,990 characters if used as a Welcome Message.

Action 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 Connect Twitter Developer App + HTTP / Webhook

Send Direct Message (DM) with Twitter Developer App API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + Twitter Developer App
 
Try it
Send Direct Message (DM) with Twitter Developer App API on New event when the content of the URL changes. from HTTP / Webhook API
HTTP / Webhook + Twitter Developer App
 
Try it
Custom Request with HTTP / Webhook API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + HTTP / Webhook
 
Try it
GET Request with HTTP / Webhook API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + HTTP / Webhook
 
Try it
POST Request with HTTP / Webhook API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + HTTP / Webhook
 
Try it
New Requests from the HTTP / Webhook API

Get a URL and emit the full HTTP event on every request (including headers and query parameters). You can also configure the HTTP response code, body, and more.

 
Try it
New Requests (Payload Only) from the HTTP / Webhook API

Get a URL and emit the HTTP body as an event on every request

 
Try it
New event when the content of the URL changes. from the HTTP / Webhook API

Emit new event when the content of the URL changes.

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

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

 
Try it
Send any HTTP Request with the HTTP / Webhook API

Send an HTTP request using any method and URL. Optionally configure query string parameters, headers, and basic auth.

 
Try it
Send GET Request with the HTTP / Webhook API

Send an HTTP GET request to any URL. Optionally configure query string parameters, headers and basic auth.

 
Try it
Send POST Request with the HTTP / Webhook API

Send an HTTP POST request to any URL. Optionally configure query string parameters, headers and basic auth.

 
Try it
Send PUT Request with the HTTP / Webhook API

Send an HTTP PUT request to any URL. Optionally configure query string parameters, headers and basic auth.

 
Try it
Return HTTP Response with the HTTP / Webhook API

Use with an HTTP Source that uses Return a custom response from your workflow as its HTTP Response

 
Try it