Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions components/wordpress_com/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,33 @@ The Wordpress.com API empowers developers to extend and integrate their website'
- **Comment Moderation Alerts**: Set up a Pipedream workflow that monitors Wordpress.com for new comments. When a comment is detected, analyze its content for specific keywords or sentiment using a service like Google's Natural Language API. If the comment requires attention (e.g., contains flagged words or negative sentiment), send an immediate alert to a Slack channel or via email to prompt review and moderation, keeping your community healthy and engaged.

- **User Synchronization and Engagement**: Create a workflow that triggers when a new user registers on your Wordpress.com site. This workflow can add the user to a CRM like HubSpot or Salesforce, subscribe them to a Mailchimp email list, and even send a personalized welcome email via SendGrid. This ensures your user data is consistent across platforms and kickstarts the user engagement process from the moment they sign up.


# Available Event Sources

Trigger workflows automatically when specific Wordpress.com events occur:

New Post: Emit a new event when a post, page, or media attachment is published.
Required props: site ID or URL. Optional: post type (post, page, attachment).

New Comment: Emit a new event when a comment is added to any post or page.
Required props: site ID or URL. Optional: post ID to filter comments.

New Follower: Emit a new event when someone subscribes to the site's blog.
Required props: site ID or URL.

Each source manages its own database cursor to ensure only new data is processed each time it runs — no duplicates, no missed updates.
Available Actions

Perform direct operations on your Wordpress.com site:

Create Post: Create a new post on the site.
Required props: site ID or URL, post title, post content.
Optional props: post status (draft, published), categories, and tags.

Upload Media: Upload a media file (image, video, etc.) to the site's library.
Required props: site ID or URL, media file (binary or URL).
Optional props: media title and description.

Delete Post: Delete an existing post from the site.
Required props: site ID or URL, post ID.
90 changes: 90 additions & 0 deletions components/wordpress_com/actions/create-post/create-post.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import wordpress from "../../wordpress_com.app.mjs";

export default {
key: "wordpress_com-create-post",
name: "Create New Post",
description: "Creates a new post on a WordPress.com site.",
version: "0.0.5",
type: "action",
props: {
wordpress,
site: {
type: "string",
label: "Site ID or domain",
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
},
title: {
type: "string",
label: "Post Title",
description: "The title of the post.",
},
content: {
type: "string",
label: "Post Content",
description: "The content of the post (HTML or text).",
},
status: {
type: "string",
label: "Status",
description: "The status of the post.",
options: [
"publish",
"draft",
"private",
"pending",
],
default: "draft",
optional: true,
},
type: {
type: "string",
label: "Post Type",
description: "The type of the post (post or page). For attachments, use the 'Upload Media' action.",
options: [
{
label: "Post",
value: "post",
},
{
label: "Page",
value: "page",
},
],
default: "post",
optional: true,
},
},

async run({ $ }) {

const warnings = [];

const {
site,
wordpress,
...fields
} = this;

warnings.push(...wordpress.checkDomainOrId(site)); // TEST

let response;

try {
response = await wordpress.createWordpressPost({ //TEST

$,
site,
data: {
...fields,
},
});

} catch (error) {
wordpress.throwCustomError("Could not create post", error, warnings);
};

$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));
},

};

51 changes: 51 additions & 0 deletions components/wordpress_com/actions/delete-post/delete-post.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import wordpress from "../../wordpress_com.app.mjs";

export default {

key: "wordpress_com-delete-post",
name: "Delete Post",
description: "Deletes a post",
version: "0.0.4",
type: "action",
props: {
wordpress,
site: {
label: "Domain or ID",
type: "string",
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
},
postId: {
type: "integer",
label: "Post ID",
description: "The ID of the post you want to delete.",
},
},

async run({ $ }) {

const warnings = [];

const {
site,
wordpress,
postId,
} = this;

warnings.push(...wordpress.checkDomainOrId(site));

let response;

try {
response = await wordpress.deleteWordpressPost({
$,
site,
postId,
});
} catch (error) {
wordpress.throwCustomError("Could not delete post", error, warnings);
};

$.export("$summary", `Post ID = ${response?.ID} successfully deleted.` + "\n- " + warnings.join("\n- "));
},
};

94 changes: 94 additions & 0 deletions components/wordpress_com/actions/upload-media/upload-media.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { prepareMediaUpload } from "../../common/utils.mjs";
import wordpress from "../../wordpress_com.app.mjs";

export default {

key: "wordpress_com-upload-media",
name: "Upload Media",
description: "Uploads a media file from a URL to the specified WordPress.com site.",
version: "0.0.4",
type: "action",

props: {
wordpress,
site: {
type: "string",
label: "Site ID or domain",
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
},
media: {
type: "any",
label: "Media URL",
description: "A direct media URL, or a FormData object with the file attached under the field name 'media[]'.",
},
title: {
type: "string",
label: "Title",
description: "Title of the media.",
optional: true,
},
caption: {
type: "string",
label: "Caption",
description: "Optional caption text to associate with the uploaded media.",
optional: true,
},
description: {

Check warning on line 36 in components/wordpress_com/actions/upload-media/upload-media.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop description must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "string",
label: "Description",
optional: true,
},
},

async run({ $ }) {

const warnings = [];

const
{
wordpress,
site,
media,
...fields
} = this;

warnings.push(...wordpress.checkDomainOrId(site));

let form;

// If not form data
if (wordpress.isFormData(media)) {

form = media;

} else {

form = await prepareMediaUpload(media, fields, $);
}

let response;

try {

response = await wordpress.uploadWordpressMedia({
$,
contentType: form.getHeaders()["content-type"],
site,
data: form,
});

const media = response.media[0];

$.export("$summary", `Media "${media.title}" uploaded successfully (ID: ${media.ID})` + "\n- " + warnings.join("\n- "));

console.log(response);
return response;

} catch (error) {

wordpress.throwCustomError("Failed to upload media", error, warnings);

};
},
};

Loading
Loading