Problem with webhook reponse body

I am trying to make use of Resend (SMTP service) receive API. Resend node.js module library already loaded in N8N image.

I have a webhook trigger. It’s triggered properly and can return the details

Then next block is using “Execute code” to GET message body from Resend.

I’ve used this command

node -e "const { Resend } = require('resend');const resend = new Resend('re_XXXXXXXX');(async () => {const { data, error } = await resend.emails.receiving.get('{{ $json.body.data.email_id }}',);})();"

Once executed, it prompt a green tick but return nothing.

1 item
[
{
"exitCode": 
0,
"stderr": 
"",
"stdout": 
""
}
]

However, from RESEND portal, I can see it’s delivered message body.

Hello @jasonwch
Is there any specific reason you’re using the Execute Command node?You could just use the Code node instead..
However, I think you can skip both and make a direct HTTP reques, Resend already supports that according to their docs:

Thanks so much for your quick reply. Sorry that I am new to Node / N8N world.

Do you mean Code node → Javascript? May I know if this node support the modules I’ve loaded into the container?

And I’ve read and followed the guide on your attached Resend official doc → Node.js part. I think it require to load the module ([email protected]) first (which I did), then still use webhook to take the values? Or I am understanding wrong and need to make HTTP request? If so, how?

No problem. I’d just recommend not using the Execute Command or even the Code node unless there’s something you can’t achieve with a simple HTTP request, which is possible most of the time.

In your case, you can simply call this endpoint to retrieve received email without running any commands, writing custom code, or installing any libraries in the n8n image:

as you can see they are supporting cURL:

1 Like

omg, you saved me…I didn’t realize the last option to use CURL which make thing much more easier. Now I’ve got the JSON……Will figure out the way to parse the outlook, especially converting HTML to text…….If possible, can you give me some hints on using which kind of node…

Thanks again!!!

Dont worry, I’ve figured it out

using CURL even don require install custom library……thanks so much

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.