Gmail Developer API

I setup the gmail dev api, but need to access the full body of the email for the next step. I can’t find it anywhere. Any help is appreciated.

Hi @jordanbellinger,

First off, welcome to Pipedream! Happy to have you.

What specific Gmail Trigger/Action you’re using?

Thanks. I’m loving the software, but not an expert in any of this. Thanks for your help. I’m using the gmail dev API that is triggered by a new email received. Then I want to copy the path of the email, send to Open AI and get a summary.

Hi @jordanbellinger, I have tested and I can see the body in the snippet field as in the image below

Please connect your Google Gmail account again, make sure you have checked the box to allow Pipedream to read your email

I have the snippet too, but if the email is longer than a few lines it won’t grab the entire thing. I’ve been using snippet, but the functionality is limited for my use case.

Hi @jordanbellinger,

Thanks for raising this. I can reproduce your issue and I have created a ticket here for Pipedream team to improve the Gmail - New Email source.

The reason you don’t see the full content is that they have been encoded in base64 in the event body. As a workaround for now, you can add a Node.js code step into your workflow to decode the body, then you will be able to get the whole content. Here’s the sample workflow:

Here’s the code for Node.js code step:

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    const base64EncodedString =[0];
    const buffer = Buffer.from(base64EncodedString, 'base64');
    const decodedString = buffer.toString('ascii');
    // Return data to use it in future steps
    return decodedString

That is excellent and worked really well. Now i’m running into an error with GPT summarize because the data is too many characters. Any idea on how to make this smaller?


From my understanding, you will need to use Node.js code step to split your message to multiple parts and send it to Open AI API. I think this need a sufficient coding knowledge to implement, I haven’t try it.

ok. thanks again