@pipedream/twitter 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Overview
2
+
3
+ The Twitter API on Pipedream enables you to automate interactions with Twitter, from posting tweets to analyzing social media trends. Pipedream's serverless platform provides the tools to create workflows that trigger on specific Twitter activities, process data, and connect with countless other apps for extensive automation scenarios. With Pipedream's integration, you can listen for events such as new tweets, mentions, or followers, and execute actions like tweeting, retweeting, or even leveraging sentiment analysis to gauge public perception.
4
+
5
+
1
6
  # Getting Started
2
7
  In order to connect your Twitter account to Pipedream, you'll need to create a developer project and app.
3
8
  1. First, visit Twitter's [developer dashboard](https://developer.twitter.com/en/portal/dashboard) and sign in
@@ -19,6 +24,14 @@ In order to connect your Twitter account to Pipedream, you'll need to create a d
19
24
 
20
25
  ![Consumer API key](https://res.cloudinary.com/dpenc2lit/image/upload/v1684365722/Screenshot_2023-05-17_at_4.19.52_PM_jlvbvw.png)
21
26
 
27
+ # Example Use Cases
28
+
29
+ - **Automated Tweeting of Curated Content:** Create a workflow that monitors RSS feeds or other content sources. When new items are detected, format the content and automatically post it to your Twitter account, keeping your followers engaged with fresh and relevant content.
30
+
31
+ - **Twitter Sentiment Analysis:** Set up a workflow that triggers on new mentions of your username on Twitter. Pass the tweet text to a sentiment analysis service like Google's Natural Language API to determine the emotion conveyed. Use this data to respond appropriately or to gather insights on public perception.
32
+
33
+ - **Customer Support Ticketing:** Develop a workflow that starts when your company's Twitter account receives a direct message. Automatically create a ticket in a customer support platform like Zendesk or HubSpot, ensuring that your team promptly addresses customer inquiries and issues mentioned on Twitter.
34
+
22
35
  # Troubleshooting
23
36
  Below are some of the most common issues we see.
24
37
 
@@ -13,7 +13,7 @@ declare const _default: import("@pipedream/types").Action<unknown, {
13
13
  getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
14
14
  getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
15
15
  getAuthenticatedUser(args: import("../../common/types/requestParams.js").GetAuthenticatedUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
16
- getAuthenticatedUserId(): Promise<string>;
16
+ getAuthenticatedUserId(): Promise<import("../../common/types/responseSchemas.js").User["id"]>;
17
17
  getDirectMessages(args: import("../../common/types/requestParams.js").GetDirectMessagesParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").DirectMessage>>;
18
18
  getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
19
19
  getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").List>>;
@@ -24,8 +24,8 @@ declare const _default: import("@pipedream/types").Action<unknown, {
24
24
  getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
25
25
  likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
26
26
  getUserFollowers({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
27
- getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
28
- retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
27
+ getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowingParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
28
+ retweet(args: import("../../common/types/requestParams.js").RetweetParams): Promise<object>;
29
29
  searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
30
30
  sendMessage({ userId, ...args }: import("../../common/types/requestParams.js").SendMessageParams): Promise<object>;
31
31
  unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;
@@ -2,8 +2,7 @@ import common from "../../common/appValidation.mjs";
2
2
  import { ACTION_ERROR_MESSAGE } from "../../common/errorMessage.mjs";
3
3
  import { defineAction } from "@pipedream/types";
4
4
  import constants from "../../common/constants.mjs";
5
- import fs from "fs";
6
- import { axios } from "@pipedream/platform";
5
+ import { getFileStreamAndMetadata } from "@pipedream/platform";
7
6
  import FormData from "form-data";
8
7
  const DOCS_LINK = "https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload";
9
8
  export default defineAction({
@@ -11,15 +10,14 @@ export default defineAction({
11
10
  key: "twitter-upload-media",
12
11
  name: "Upload Media",
13
12
  description: `Upload new media. [See the documentation](${DOCS_LINK})`,
14
- version: "0.0.12",
13
+ version: "0.0.13",
15
14
  type: "action",
16
15
  props: {
17
16
  ...common.props,
18
17
  filePath: {
19
18
  type: "string",
20
- label: "File Path",
21
- description: "A file URL or a file path in the `/tmp` directory. [See the documentation on working with files.](https://pipedream.com/docs/code/nodejs/working-with-files/)",
22
- optional: false,
19
+ label: "File Path or URL",
20
+ description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
23
21
  },
24
22
  media_category: {
25
23
  type: "string",
@@ -30,29 +28,22 @@ export default defineAction({
30
28
  },
31
29
  },
32
30
  async run({ $ }) {
33
- const isLocalFile = this.filePath?.startsWith("/tmp");
34
- let content;
31
+ let content, meta;
35
32
  try {
36
- content = isLocalFile
37
- ? fs.createReadStream(this.filePath, {
38
- encoding: "base64",
39
- })
40
- : await axios($, {
41
- url: this.filePath,
42
- responseType: "arraybuffer",
43
- });
33
+ const { stream, metadata, } = await getFileStreamAndMetadata(this.filePath);
34
+ content = stream;
35
+ meta = metadata;
44
36
  }
45
37
  catch (err) {
46
38
  $.export("error", err);
47
39
  throw new Error(ACTION_ERROR_MESSAGE);
48
40
  }
49
41
  const data = new FormData();
50
- if (isLocalFile) {
51
- data.append("media_data", content);
52
- }
53
- else {
54
- data.append("media", content);
55
- }
42
+ data.append("media_data", content, {
43
+ contentType: meta.contentType,
44
+ knownLength: meta.size,
45
+ filename: meta.name,
46
+ });
56
47
  const response = await this.app.uploadMedia({
57
48
  $,
58
49
  data,
@@ -8,12 +8,12 @@ import {
8
8
  POLL_FIELD_OPTIONS,
9
9
  TWEET_FIELD_OPTIONS,
10
10
  USER_FIELD_OPTIONS,
11
- } from "./dataFields.mjs";
11
+ } from "./dataFields";
12
12
  import {
13
13
  LIST_EXPANSION_OPTIONS,
14
14
  TWEET_EXPANSION_OPTIONS,
15
15
  USER_EXPANSION_OPTIONS,
16
- } from "./expansions.mjs";
16
+ } from "./expansions";
17
17
 
18
18
  // These cannot be propDefinitions in the app file, because additionalProps() needs them to be primitives
19
19
  const listExpansions = {
@@ -51,7 +51,7 @@ declare const _default: {
51
51
  getListTweets({ listId, ...args }: import("./types/requestParams.js").GetListTweetsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
52
52
  getTweet({ tweetId, ...args }: import("./types/requestParams.js").GetTweetParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").Tweet>>;
53
53
  getAuthenticatedUser(args: import("./types/requestParams.js").GetAuthenticatedUserParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").User>>;
54
- getAuthenticatedUserId(): Promise<string>;
54
+ getAuthenticatedUserId(): Promise<import("./types/responseSchemas.js").User["id"]>;
55
55
  getDirectMessages(args: import("./types/requestParams.js").GetDirectMessagesParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").DirectMessage>>;
56
56
  getUserLikedTweets({ userId, ...args }: import("./types/requestParams.js").GetUserLikedTweetParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
57
57
  getUserOwnedLists({ userId, ...args }: import("./types/requestParams.js").GetUserOwnedListsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").List>>;
@@ -62,8 +62,8 @@ declare const _default: {
62
62
  getUser({ userId, ...args }: import("./types/requestParams.js").GetUserParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").User>>;
63
63
  likeTweet(args: import("./types/requestParams.js").LikeTweetParams): Promise<object>;
64
64
  getUserFollowers({ userId, ...args }: import("./types/requestParams.js").GetUserFollowersParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
65
- getUserFollowing({ userId, ...args }: import("./types/requestParams.js").GetUserFollowersParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
66
- retweet(args: import("./types/requestParams.js").LikeTweetParams): Promise<object>;
65
+ getUserFollowing({ userId, ...args }: import("./types/requestParams.js").GetUserFollowingParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
66
+ retweet(args: import("./types/requestParams.js").RetweetParams): Promise<object>;
67
67
  searchTweets(args: import("./types/requestParams.js").SearchTweetsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
68
68
  sendMessage({ userId, ...args }: import("./types/requestParams.js").SendMessageParams): Promise<object>;
69
69
  unfollowUser({ userId, ...args }: import("./types/requestParams.js").UnfollowUserParams): Promise<object>;
@@ -82,7 +82,7 @@ declare const _default: {
82
82
  getListTweets({ listId, ...args }: import("./types/requestParams.js").GetListTweetsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
83
83
  getTweet({ tweetId, ...args }: import("./types/requestParams.js").GetTweetParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").Tweet>>;
84
84
  getAuthenticatedUser(args: import("./types/requestParams.js").GetAuthenticatedUserParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").User>>;
85
- getAuthenticatedUserId(): Promise<string>;
85
+ getAuthenticatedUserId(): Promise<import("./types/responseSchemas.js").User["id"]>;
86
86
  getDirectMessages(args: import("./types/requestParams.js").GetDirectMessagesParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").DirectMessage>>;
87
87
  getUserLikedTweets({ userId, ...args }: import("./types/requestParams.js").GetUserLikedTweetParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
88
88
  getUserOwnedLists({ userId, ...args }: import("./types/requestParams.js").GetUserOwnedListsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").List>>;
@@ -93,8 +93,8 @@ declare const _default: {
93
93
  getUser({ userId, ...args }: import("./types/requestParams.js").GetUserParams): Promise<import("./types/responseSchemas.js").ResponseObject<import("./types/responseSchemas.js").User>>;
94
94
  likeTweet(args: import("./types/requestParams.js").LikeTweetParams): Promise<object>;
95
95
  getUserFollowers({ userId, ...args }: import("./types/requestParams.js").GetUserFollowersParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
96
- getUserFollowing({ userId, ...args }: import("./types/requestParams.js").GetUserFollowersParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
97
- retweet(args: import("./types/requestParams.js").LikeTweetParams): Promise<object>;
96
+ getUserFollowing({ userId, ...args }: import("./types/requestParams.js").GetUserFollowingParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").User>>;
97
+ retweet(args: import("./types/requestParams.js").RetweetParams): Promise<object>;
98
98
  searchTweets(args: import("./types/requestParams.js").SearchTweetsParams): Promise<import("./types/responseSchemas.js").PaginatedResponseObject<import("./types/responseSchemas.js").Tweet>>;
99
99
  sendMessage({ userId, ...args }: import("./types/requestParams.js").SendMessageParams): Promise<object>;
100
100
  unfollowUser({ userId, ...args }: import("./types/requestParams.js").UnfollowUserParams): Promise<object>;
@@ -59,7 +59,7 @@ declare const _default: {
59
59
  getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
60
60
  getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
61
61
  getAuthenticatedUser(args: import("../../common/types/requestParams.js").GetAuthenticatedUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
62
- getAuthenticatedUserId(): Promise<string>;
62
+ getAuthenticatedUserId(): Promise<import("../../common/types/responseSchemas.js").User["id"]>;
63
63
  getDirectMessages(args: import("../../common/types/requestParams.js").GetDirectMessagesParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").DirectMessage>>;
64
64
  getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
65
65
  getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").List>>;
@@ -70,8 +70,8 @@ declare const _default: {
70
70
  getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
71
71
  likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
72
72
  getUserFollowers({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
73
- getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
74
- retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
73
+ getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowingParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
74
+ retweet(args: import("../../common/types/requestParams.js").RetweetParams): Promise<object>;
75
75
  searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
76
76
  sendMessage({ userId, ...args }: import("../../common/types/requestParams.js").SendMessageParams): Promise<object>;
77
77
  unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;
@@ -90,7 +90,7 @@ declare const _default: {
90
90
  getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
91
91
  getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
92
92
  getAuthenticatedUser(args: import("../../common/types/requestParams.js").GetAuthenticatedUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
93
- getAuthenticatedUserId(): Promise<string>;
93
+ getAuthenticatedUserId(): Promise<import("../../common/types/responseSchemas.js").User["id"]>;
94
94
  getDirectMessages(args: import("../../common/types/requestParams.js").GetDirectMessagesParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").DirectMessage>>;
95
95
  getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
96
96
  getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").List>>;
@@ -101,8 +101,8 @@ declare const _default: {
101
101
  getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas.js").ResponseObject<import("../../common/types/responseSchemas.js").User>>;
102
102
  likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
103
103
  getUserFollowers({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
104
- getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
105
- retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
104
+ getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowingParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").User>>;
105
+ retweet(args: import("../../common/types/requestParams.js").RetweetParams): Promise<object>;
106
106
  searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas.js").PaginatedResponseObject<import("../../common/types/responseSchemas.js").Tweet>>;
107
107
  sendMessage({ userId, ...args }: import("../../common/types/requestParams.js").SendMessageParams): Promise<object>;
108
108
  unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;