What are the Correct Values and Actions to Automate WordPress Blog Post Publishing in Pipedream?

created post has only h1 title without content.
Step 3 code that I used

import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
google: {
type: “app”,
app: “google”,
},
},
async run({ steps, $ }) {
const folderId = “1Sd-4LdWthAZrl46-BiMHh59sW5alUG0-”;
const fileListResponse = await axios($, {
method: “GET”,
url: “https://www.googleapis.com/drive/v3/files”,
params: {
q: '${folderId}' in parents,
orderBy: “createdTime desc”,
pageSize: 1,
},
headers: {
Authorization: Bearer ${**this**.google.$auth.oauth_access_token},
},
});

**if** (
  fileListResponse.data &&
  fileListResponse.data.files &&
  fileListResponse.data.files.length > 0
) {
  **const** latestFileId = fileListResponse.data.files[0].id;
  _// Rest of the code_
} **else** {
  console.log("No files found in the specified folder.");
}

},
});
Step 4 code that I used
import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
wordpress_org: {
type: “app”,
app: “wordpress_org”,
},
title: {
type: “string”,
label: “Post Title”,
},
content: {
type: “string”,
label: “Post Content”,
},
},
async run({ $ }) {
const endpoint = “https://digitaltopical.com/wp-json/wp/v2/posts”;
const auth = Buffer.from(${**this**.wordpress_org.$auth.username}:${**this**.wordpress_org.$auth.application_password}).toString(“base64”);

**const** response = **await** axios($, {
  method: "POST",
  url: endpoint,
  headers: {
    Authorization: `Basic ${auth}`,
  },
  data: {
    title: **this**.title,
    content: **this**.content,
  },
});

**return** response;

},
});
Step 5 configured
Title

steps.step3.file

Title of the post
Content

steps.step3.content

but has error
Error
Autodiscovery failed

I apologize for the confusion. It seems there might be an issue with the way the title and content are being passed in Step 5. Please make sure you’re using the correct variable names for the title and content in Step 5. If you’re still facing issues, please provide more information about the error message or the code in Step 5, so I can help you better.

created post has only h1 title without content. The H1 title is written by step 5 configure.

Step 3 code that I used

import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
google: {
type: “app”,
app: “google”,
},
},
async run({ steps, $ }) {
const folderId = “1Sd-4LdWthAZrl46-BiMHh59sW5alUG0-”;
const fileListResponse = await axios($, {
method: “GET”,
url: “https://www.googleapis.com/drive/v3/files”,
params: {
q: '${folderId}' in parents,
orderBy: “createdTime desc”,
pageSize: 1,
},
headers: {
Authorization: Bearer ${**this**.google.$auth.oauth_access_token},
},
});

**if** (
  fileListResponse.data &&
  fileListResponse.data.files &&
  fileListResponse.data.files.length > 0
) {
  **const** latestFileId = fileListResponse.data.files[0].id;
  _// Rest of the code_
} **else** {
  console.log("No files found in the specified folder.");
}

},
});

Step 4 code that I used

import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
wordpress_org: {
type: “app”,
app: “wordpress_org”,
},
title: {
type: “string”,
label: “Post Title”,
},
content: {
type: “string”,
label: “Post Content”,
},
},
async run({ $ }) {
const endpoint = “https://digitaltopical.com/wp-json/wp/v2/posts”;
const auth = Buffer.from(${**this**.wordpress_org.$auth.username}:${**this**.wordpress_org.$auth.application_password}).toString(“base64”);

**const** response = **await** axios($, {
  method: "POST",
  url: endpoint,
  headers: {
    Authorization: `Basic ${auth}`,
  },
  data: {
    title: **this**.title,
    content: **this**.content,
  },
});

**return** response;

},
});

Step 5 configured

Title

steps.step3.file

Title of the post
Content

steps.step3.content

but has error
Error
Autodiscovery failed (edited)

what should I type on step 5, configure for title and content?

My current input
Title

steps.step3.file

Title of the post
Content

steps.step3.content

I see that you’re trying to use the output from Step 3 as the title and content for the Wordpress post in Step 5. Based on the code you provided for Step 3, it seems that you’re not returning the title and content from that step. To fix this, you should modify the code in Step 3 to return the title and content as an object. Here’s an example of how you can do this: In Step 3, after obtaining the latestFileId, you should fetch the file content and return it along with the title. You can update the code like this: const file = fileListResponse.data.files[0]; const fileContentResponse = await axios($, { method: "GET", url: `https://www.googleapis.com/drive/v3/files/${latestFileId}?alt=media`, responseType: "text", headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, }); return { title: file.name, content: fileContentResponse.data, }; Now, in Step 5, you can use the output from Step 3 like this: Title steps.step3.outputs.title Content ```
steps.step3.outputs.content

can you give me the full code for step 3?

Certainly! Here’s the full code for Step 3, which fetches the latest file from Google Drive and returns its title and content: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ $ }) { const fileListResponse = await axios($, { method: "GET", url: "https://www.googleapis.com/drive/v3/files", params: { orderBy: "modifiedTime desc", pageSize: 1, fields: "files(id, name)", }, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, }); const latestFileId = fileListResponse.data.files[0].id; const file = fileListResponse.data.files[0]; const fileContentResponse = await axios($, { method: "GET", url: `https://www.googleapis.com/drive/v3/files/${latestFileId}?alt=media`, responseType: "text", headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, }); return { title: file.name, content: fileContentResponse.data, }; }, }); This code will fetch the latest file from Google Drive and return its title and content. You can then use the outputs in Step 5 as follows: Title steps.step3.outputs.title Content ```
steps.step3.outputs.content

, for step 3, I replaced the code you gave me. But I have an error.
TypeError
Cannot read properties of undefined (reading ‘$auth’)

I apologize for the confusion. It seems I missed adding the google prop to the component, which is required to access the this.google.$auth.oauth_access_token. Here’s the updated code for Step 3: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google_drive”, }, }, async run({ $ }) { const fileListResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/drive/v3/files”, params: { orderBy: “modifiedTime desc”, pageSize: 1, fields: “files(id, name)”, }, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); const latestFileId = fileListResponse.data.files[0].id; const file = fileListResponse.data.files[0]; const fileContentResponse = await axios($, { method: “GET”, url: https://www.googleapis.com/drive/v3/files/${latestFileId}?alt=media, responseType: “text”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); return { title: file.name, content: fileContentResponse.data, }; }, });

I got an error on step 3.
TypeError
Cannot read properties of undefined (reading ‘files’)
DETAILS

Detailed/code mode
Google Drive Account
kc@digitaltopical.com

code_1

CONFIGURE

CODE

create_post

CONFIGURE

<hrp-shortcut class=“hrp-container” style=“box-sizing: border-box; border-width: 0px; border-style: solid; border-color: transparent; --tw-ring-inset: var(–tw-empty, ); --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(51, 170, 255, .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; position: fixed; bottom: 24px; right: 24px; z-index: 2147483646; opacity: 1; height: 30px; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px; border-radius: 4px; background-color: rgb(255, 255, 255); display: flex; flex-direction: row; align-items: center; transition: box-shadow 0.15s ease-in-out 0s;”>

⌃ A

I apologize for the issue you’re facing. It seems there might be a problem with the response from the Google Drive API. To better understand the issue, let’s add some error handling and logging to the code. Please replace the code in Step 3 with the following: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google_drive”, }, }, async run({ $ }) { try { const fileListResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/drive/v3/files”, params: { orderBy: “modifiedTime desc”, pageSize: 1, fields: “files(id, name)”, }, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); if (!fileListResponse.data.files || fileListResponse.data.files.length === 0) { console.log(“No files found”); return; } const latestFileId = fileListResponse.data.files[0].id; const file = fileListResponse.data.files[0]; const fileContentResponse = await axios($, { method: “GET”, url: https://www.googleapis.com/drive/v3/files/${latestFileId}?alt=media, responseType: “text”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); return { title: file.name, content: fileContentResponse.data, }; } catch (error) { console.error(“Error:”, error); throw error; } }, });

, on step 3, there is still an error.
TypeError
Cannot read properties of undefined (reading ‘files’)

I apologize for the continued issue. Let’s add more detailed logging to help identify the problem. Please update the code in Step 3 with the following: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google_drive”, }, }, async run({ $ }) { try { const fileListResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/drive/v3/files”, params: { orderBy: “modifiedTime desc”, pageSize: 1, fields: “files(id, name)”, }, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); console.log(“File list response:”, fileListResponse); if (!fileListResponse.files || fileListResponse.files.length === 0) { console.log(“No files found”); return; } const latestFileId = fileListResponse.files[0].id; const file = fileListResponse.files[0]; const fileContentResponse = await axios($, { method: “GET”, url: https://www.googleapis.com/drive/v3/files/${latestFileId}?alt=media, responseType: “text”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); return { title: file.name, content: fileContentResponse.data, }; } catch (error) { console.error(“Error:”, error); throw error; } }, });

Another error on step 3.
Error - Request failed with status code 403
{“error”:{“code”:403,“message”:“Only files with binary content can be downloaded. Use Export with Docs Editors files.”,“errors”:[{“message”:“Only files with binary content can be downloaded. Use Export with Docs Editors files.”,“domain”:“global”,“reason”:“fileNotDownloadable”,“location”:“alt”,“locationType”:“parameter”}]}}

I apologize for the inconvenience. The error message indicates that the file you’re trying to download is not a binary file, but a Google Docs file. To download the content of a Google Docs file, you’ll need to use the Google Drive API’s export method instead of the download method. Please update the code in Step 3 with the following: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google_drive”, }, }, async run({ $ }) { try { const fileListResponse = await axios($, { method: “GET”, url: “https://www.googleapis.com/drive/v3/files”, params: { orderBy: “modifiedTime desc”, pageSize: 1, fields: “files(id, name, mimeType)”, }, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); console.log(“File list response:”, fileListResponse); if (!fileListResponse.files || fileListResponse.files.length === 0) { console.log(“No files found”); return; } const latestFileId = fileListResponse.files[0].id; const file = fileListResponse.files[0]; const mimeType = file.mimeType; let exportUrl = https://www.googleapis.com/drive/v3/files/${latestFileId}/export; let responseType = “text”; if (mimeType === “application/vnd.google-apps.document”) { exportUrl += “?mimeType=text/plain”; } else if (mimeType === “application/vnd.google-apps.spreadsheet”) { exportUrl += “?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”; responseType = “arraybuffer”; } else { console.log(“Unsupported file type for export”); return; } const fileContentResponse = await axios($, { method: “GET”, url: exportUrl, responseType: responseType, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); return { title: file.name, content: fileContentResponse.data, }; } catch (error) { console.error(“Error:”, error); throw error; } }, });

Step5 has an error.
Error
Autodiscovery failed

Current Input
Title

steps.step3.outputs.title

Title of the post
Content

steps.step3.outputs.content

How to fix it?

I apologize for the inconvenience. It seems like there’s an issue with the autodiscovery of the variables in Step 5. To fix this, you can manually reference the outputs from Step 3 in Step 5 using the correct syntax. Replace the current input in Step 5 with the following: Title {{steps.step3.outputs.title}} Content ```
{{steps.step3.outputs.content}}

same error on step 5.
Error
Autodiscovery failed

I apologize for the confusion. It seems I misunderstood your issue earlier. The “Autodiscovery failed” error is related to the Pipedream UI and not the code itself. To help you better, can you please provide more information about the workflow you’re working on? Specifically, what are the components or actions in the previous steps, and what is the expected outcome for Step 5? This will help me understand the context and provide a more accurate solution.

Step 1: " Trigger" is when a Google Doc is moved to a file

Step 2: “Filter” is the file name containing “Published” at the end.

Step 3: extract file info from Google Doc ID
the code that I used
import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
google: {
type: “app”,
app: “google_drive”,
},
},
async run({ $ }) {
try {
const fileListResponse = await axios($, {
method: “GET”,
url: “https://www.googleapis.com/drive/v3/files”,
params: {
orderBy: “modifiedTime desc”,
pageSize: 1,
fields: “files(id, name, mimeType)”,
},
headers: {
Authorization: Bearer ${**this**.google.$auth.oauth_access_token},
},
});

  console.log("File list response:", fileListResponse);

  **if** (!fileListResponse.files || fileListResponse.files.length === 0) {
    console.log("No files found");
    **return**;
  }

  **const** latestFileId = fileListResponse.files[0].id;
  **const** file = fileListResponse.files[0];
  **const** mimeType = file.mimeType;

  **let** exportUrl = `https://www.googleapis.com/drive/v3/files/${latestFileId}/export`;
  **let** responseType = "text";

  **if** (mimeType === "application/vnd.google-apps.document") {
    exportUrl += "?mimeType=text/plain";
  } **else** **if** (mimeType === "application/vnd.google-apps.spreadsheet") {
    exportUrl += "?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    responseType = "arraybuffer";
  } **else** {
    console.log("Unsupported file type for export");
    **return**;
  }

  **const** fileContentResponse = **await** axios($, {
    method: "GET",
    url: exportUrl,
    responseType: responseType,
    headers: {
      Authorization: `Bearer ${**this**.google.$auth.oauth_access_token}`,
    },
  });

  **return** {
    title: file.name,
    content: fileContentResponse.data,
  };
} **catch** (error) {
  console.error("Error:", error);
  **throw** error;
}

},
});

Step 4
The code that I used
import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
wordpress_org: {
type: “app”,
app: “wordpress_org”,
},
title: {
type: “string”,
label: “Post Title”,
},
content: {
type: “string”,
label: “Post Content”,
},
},
async run({ $ }) {
const endpoint = “https://digitaltopical.com/wp-json/wp/v2/posts”;
const auth = Buffer.from(${**this**.wordpress_org.$auth.username}:${**this**.wordpress_org.$auth.application_password}).toString(“base64”);

**const** response = **await** axios($, {
  method: "POST",
  url: endpoint,
  headers: {
    Authorization: `Basic ${auth}`,
  },
  data: {
    title: **this**.title,
    content: **this**.content,
  },
});

**return** response;

},
});

Step5
Title

{{steps.step3.outputs.title}}

Title of the post
Content

{{steps.step3.outputs.content}}

The current issue is on step 5
Error
Autodiscovery failed
Published posting doesn’t have content with only H1 tag titles like step 5 configure.
I want the post’s title to be the same as the file name. And the content should be filled in rich-text format.