Why am I Receiving an Error with My Workflow Code After Three Months of Successful Use?

This topic was automatically generated from Slack. You can find the original thread here.

I created a workflow and have been using the code and workflow created by this article How to Take Perfect Notes with Your Voice Using ChatGPT and Notion
It has been working fine ( about 3 months) until today - and I am now getting this error

not sure what the error could be, some help our guidance on what to change in this code would be much appreciated

import { Client } from "@notionhq/client"
export default defineComponent({
props: {
notion: {
type: "app",
app: "notion",
}
},
async run({steps, $}) {

const notion = new Client({auth: this.notion.$auth.oauth_access_token});

// Set the page ID
const pageID = steps.notion.$return_value.response.id.replace(/-/g,'')

/** --- Send remaining Transcript blocks to the Notion Page --- **/

// Push the additional transcript groups to the Notion page
async function sendTranscripttoNotion (transcript) {

const data = {
block_id: pageID,
children: []
}

for (let sentence of transcript) {
const paragraphBlock = {
"paragraph": {
"rich_text": [
{
"text": {
"content": sentence
}
}
]
}
};

data.children.push(paragraphBlock)
}

const response = await notion.blocks.children.append(data)
return response
}

const transcriptArray = steps.notion.$return_value.transcript
transcriptArray.shift()
const transcriptAdditionResponses = []
for (let transcript of transcriptArray) {
const response = await sendTranscripttoNotion(transcript)
transcriptAdditionResponses.push(response)
}

/** --- Send the Additional Info to the Notion Page --- **/

// Split the additional info array into blocks of 95 blocks max
const additionalInfo = steps.notion.$return_value.additional_info
const infoHolder = []
const infoBlockMaxLength = 95

for (let i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) {
const chunk = additionalInfo.slice(i, i + infoBlockMaxLength)
infoHolder.push(chunk)
}

// Now send all the additional info to Notion
async function sendAdditionalInfotoNotion (info) {

const data = {
block_id: pageID,
children: []
}

for (let block of info) {
data.children.push(block)
}

const response = await notion.blocks.children.append(data)
return response

}

const additionalInfoAdditionResponses = []
for (let addition of infoHolder) {
const response = await sendAdditionalInfotoNotion(addition)
additionalInfoAdditionResponses.push(response)
}

const allAPIResponses = {
transcript_responses: transcriptAdditionResponses,
additional_info_responses: additionalInfoAdditionResponses
}

return allAPIResponses

},
})

I’m sorry to hear that you’re experiencing issues with your workflow. Based on the code you provided, it seems to be using the Notion API to append blocks to a page. To help you better, I’ll need more information about the error message you’re encountering. Can you please provide the error message or any additional details about the issue?

this is the error message

APIResponseError
Unsaved transactions: Unrecognized error.
DETAILS

    at null.buildRequestError (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/errors.js:162:16)
    at Client.request (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/Client.js:378:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.sendAdditionalInfotoNotion (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:78:24)
    at Object.run (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:85:24)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
 at null.buildRequestError (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/errors.js:162:16)
    at Client.request (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/Client.js:378:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.sendAdditionalInfotoNotion (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:78:24)
    at Object.run (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:85:24)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

his is the error message

APIResponseError
Unsaved transactions: Unrecognized error.
DETAILS

    at null.buildRequestError (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/errors.js:162:16)
    at Client.request (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/Client.js:378:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.sendAdditionalInfotoNotion (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:78:24)
    at Object.run (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:85:24)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I see you’re encountering an error with the Notion API. It seems like there’s an issue with the request being made in the sendAdditionalInfotoNotion function. To help you better, I’ll need more information about the code and what you’re trying to achieve. Can you please provide more context or share the relevant code snippet?

here is the code

here is the code

import { Client } from@notionhq/client”
export default defineComponent({
props: {
notion: {
type: “app”,
app: “notion”,
}
},
async run({steps, $}) {

**const** notion = **new** Client({auth: **this**.notion.$auth.oauth_access_token});

_// Set the page ID_
**const** pageID = steps.notion.$return_value.response.id.replace(/-/**g**,'')

_/** --- Send remaining Transcript blocks to the Notion Page --- **/_

_// Push the additional transcript groups to the Notion page_
**async** **function** sendTranscripttoNotion (transcript) {

  **const** data = {
    block_id: pageID,
    children: []
  }

  **for** (**let** sentence **of** transcript) {
    **const** paragraphBlock = {
      "paragraph": {
        "rich_text": [
          {
            "text": {
              "content": sentence
            }
          }
        ]
      }
    };

    data.children.push(paragraphBlock)
  }

  **const** response = **await** notion.blocks.children.append(data)
  **return** response
}

**const** transcriptArray = steps.notion.$return_value.transcript
transcriptArray.shift()
**const** transcriptAdditionResponses = []
**for** (**let** transcript **of** transcriptArray) {
  **const** response = **await** sendTranscripttoNotion(transcript)
  transcriptAdditionResponses.push(response)
}

_/** --- Send the Additional Info to the Notion Page --- **/_

_// Split the additional info array into blocks of 95 blocks max_
**const** additionalInfo = steps.notion.$return_value.additional_info
**const** infoHolder = []
**const** infoBlockMaxLength = 95

**for** (**let** i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) {
  **const** chunk = additionalInfo.slice(i, i + infoBlockMaxLength)
  infoHolder.push(chunk)
}

_// Now send all the additional info to Notion_
**async** **function** sendAdditionalInfotoNotion (info) {

  **const** data = {
    block_id: pageID,
    children: []
  }

  **for** (**let** block **of** info) {
    data.children.push(block)
  }

  **const** response = **await** notion.blocks.children.append(data)
  **return** response

}

**const** additionalInfoAdditionResponses = []
**for** (**let** addition **of** infoHolder) {
  **const** response = **await** sendAdditionalInfotoNotion(addition)
  additionalInfoAdditionResponses.push(response)
}

**const** allAPIResponses = {
  transcript_responses: transcriptAdditionResponses,
  additional_info_responses: additionalInfoAdditionResponses
}

**return** allAPIResponses

},
})

I see that you’ve mentioned “here is the code,” but I don’t see any code provided. Please share the relevant code snippet or more context about the issue you’re facing, so I can help you better.

It looks like you’re using the Notion API to append transcript blocks and additional information to a Notion page. Your code creates a new Notion client using the provided access token, processes the transcript and additional information arrays, and then appends them to the Notion page using the notion.blocks.children.append() method. If you have any specific questions or issues with this code, please let me know, and I’ll be happy to help!

i get this error message

APIResponseError
Unsaved transactions: Unrecognized error.
DETAILS

    at null.buildRequestError (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/errors.js:162:16)
    at Client.request (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/Client.js:378:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.sendAdditionalInfotoNotion (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:78:24)
    at Object.run (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:85:24)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

this is the code that is generating this error message

import { Client } from@notionhq/client”
export default defineComponent({
props: {
notion: {
type: “app”,
app: “notion”,
}
},
async run({steps, $}) {

**const** notion = **new** Client({auth: **this**.notion.$auth.oauth_access_token});

_// Set the page ID_
**const** pageID = steps.notion.$return_value.response.id.replace(/-/**g**,'')

_/** --- Send remaining Transcript blocks to the Notion Page --- **/_

_// Push the additional transcript groups to the Notion page_
**async** **function** sendTranscripttoNotion (transcript) {

  **const** data = {
    block_id: pageID,
    children: []
  }

  **for** (**let** sentence **of** transcript) {
    **const** paragraphBlock = {
      "paragraph": {
        "rich_text": [
          {
            "text": {
              "content": sentence
            }
          }
        ]
      }
    };

    data.children.push(paragraphBlock)
  }

  **const** response = **await** notion.blocks.children.append(data)
  **return** response
}

**const** transcriptArray = steps.notion.$return_value.transcript
transcriptArray.shift()
**const** transcriptAdditionResponses = []
**for** (**let** transcript **of** transcriptArray) {
  **const** response = **await** sendTranscripttoNotion(transcript)
  transcriptAdditionResponses.push(response)
}

_/** --- Send the Additional Info to the Notion Page --- **/_

_// Split the additional info array into blocks of 95 blocks max_
**const** additionalInfo = steps.notion.$return_value.additional_info
**const** infoHolder = []
**const** infoBlockMaxLength = 95

**for** (**let** i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) {
  **const** chunk = additionalInfo.slice(i, i + infoBlockMaxLength)
  infoHolder.push(chunk)
}

_// Now send all the additional info to Notion_
**async** **function** sendAdditionalInfotoNotion (info) {

  **const** data = {
    block_id: pageID,
    children: []
  }

  **for** (**let** block **of** info) {
    data.children.push(block)
  }

  **const** response = **await** notion.blocks.children.append(data)
  **return** response

}

**const** additionalInfoAdditionResponses = []
**for** (**let** addition **of** infoHolder) {
  **const** response = **await** sendAdditionalInfotoNotion(addition)
  additionalInfoAdditionResponses.push(response)
}

**const** allAPIResponses = {
  transcript_responses: transcriptAdditionResponses,
  additional_info_responses: additionalInfoAdditionResponses
}

**return** allAPIResponses

},
})

I’m sorry to hear that you’re encountering an error. Based on the error message, it seems like there might be an issue with the Notion API request. To better understand the issue, could you please provide more information about the specific API endpoint you’re trying to interact with and the expected outcome? This will help me assist you more effectively.

Here’s what this code is doing:
• Gets the page ID of the newly-created Notion page in the last step
• Constructs a data object, which has a children property initialized with an empty array
• Adds the rest of the transcript to the Notion page. Makes a call for each group of 80 paragraphs
• Adds all of the additional information (lists, cost/duration info, etc.) to the bottom of the Notion page
• Returns an allAPIResponses object (usually not needed, but useful for debugging)

It looks like you’re working with Notion API to create and update a page with specific content. To achieve this using Pipedream, you can use the Notion components available in the Pipedream UI. 1. First, use the “Create Page” action to create a new Notion page. You can find this action by searching for the Notion app in the step menu and selecting the “Create Page” action. Follow the instructions in the action configuration to set up the required fields. 2. Next, you can use the “Update Page” action to add content to the Notion page. You can find this action by searching for the Notion app in the step menu and selecting the “Update Page” action. In this action, you can pass the Page ID from the previous step and configure the content you want to add to the page. For more information on using these actions, please refer to the following documentation: - Create Page: https://pipedream.com/apps/notion/actions/create-page - Update Page: https://pipedream.com/apps/notion/actions/update-page Remember that you might need to split the content into smaller chunks and make multiple calls to the “Update Page” action if you’re working with a large amount of content.

I am used the JSON block with code can you suggest what changge sto make to this code

import { Client } from "@notionhq/client"
export default defineComponent({
  props: {
    notion: {
      type: "app",
      app: "notion",
    }
  },
  async run({steps, $}) {

    const notion = new Client({auth: this.notion.$auth.oauth_access_token});

    // Set the page ID
    const pageID = steps.notion.$return_value.response.id.replace(/-/g,'')

    /** --- Send remaining Transcript blocks to the Notion Page --- **/

    // Push the additional transcript groups to the Notion page
    async function sendTranscripttoNotion (transcript) {

      const data = {
        block_id: pageID,
        children: []
      }

      for (let sentence of transcript) {
        const paragraphBlock = {
          "paragraph": {
            "rich_text": [
              {
                "text": {
                  "content": sentence
                }
              }
            ]
          }
        };

        data.children.push(paragraphBlock)
      }

      const response = await notion.blocks.children.append(data)
      return response
    }

    const transcriptArray = steps.notion.$return_value.transcript
    transcriptArray.shift()
    const transcriptAdditionResponses = []
    for (let transcript of transcriptArray) {
      const response = await sendTranscripttoNotion(transcript)
      transcriptAdditionResponses.push(response)
    }

    /** --- Send the Additional Info to the Notion Page --- **/

    // Split the additional info array into blocks of 95 blocks max
    const additionalInfo = steps.notion.$return_value.additional_info
    const infoHolder = []
    const infoBlockMaxLength = 95

    for (let i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) {
      const chunk = additionalInfo.slice(i, i + infoBlockMaxLength)
      infoHolder.push(chunk)
    }

    // Now send all the additional info to Notion
    async function sendAdditionalInfotoNotion (info) {

      const data = {
        block_id: pageID,
        children: []
      }

      for (let block of info) {
        data.children.push(block)
      }

      const response = await notion.blocks.children.append(data)
      return response

    }

    const additionalInfoAdditionResponses = []
    for (let addition of infoHolder) {
      const response = await sendAdditionalInfotoNotion(addition)
      additionalInfoAdditionResponses.push(response)
    }

    const allAPIResponses = {
      transcript_responses: transcriptAdditionResponses,
      additional_info_responses: additionalInfoAdditionResponses
    }

    return allAPIResponses

  },
})

to stop this error message

APIResponseError
Unsaved transactions: Unrecognized error.

DETAILS
    at null.buildRequestError (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/errors.js:162:16)
    at Client.request (/tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/node_modules/.pnpm/@notionhq+client@2.2.13/node_modules/@notionhq/client/build/src/Client.js:378:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.sendAdditionalInfotoNotion (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:78:24)
    at Object.run (file:///tmp/__pdg__/dist/code/4ff6f0f82ce2024166e484b0ff9cee1fa48be22a428e5cf0160426a1c2d19810/component.mjs:85:24)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

It looks like you’re encountering an error when calling the notion.blocks.children.append() method. One possible issue could be the format of the data you’re sending. I noticed that you’re using the < symbol in your code, which should be replaced with the < symbol. Please update this line: for (let i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) { to: for (let i = 0; i < additionalInfo.length; i += infoBlockMaxLength ) { If the issue persists, please provide more information about the data you’re working with, such as the structure of transcriptArray and additionalInfo. This will help me better understand the problem and suggest a solution.

Might be helpful for what its worth - but the auth tokens expire after 90 days so maybe it was an Oauth issue not sure if you had done this with the API or using the token. Only reason why saying that is your comment on the 90 days

Thanks the line Pi suggested to update - fixed the issue, not sure why as they look identical but it now works?