Hi all, total newbie here. I have a webhook in my ecommerce platform setup perform an HTTP POST to pipedream when I have an order update event. I’d like to send an email out for a will call order when the status = " Ready for Pickup" do nothing for any other statuses. It’s not something the platform supports yet so trying to solve it here.
Status = steps.trigger.event.body.data.object.status
Email = steps.trigger.event.body.data.object.customer.email
Order Number = steps.trigger.event.body.data.object.id
Name = steps.trigger.event.body.data.object.customer.name
Send to = Email
Subject line = Your order {Order Number} is ready for pickup
Body = Hello {Name} your order {Order Number} is ready for pickup…blah, blah, blah.
Any help getting in the right direction is greatly appreciated.
First off, welcome to the Pipedream community. Happy to have you!
Thanks the details.
I recommend using the HTTP Webhook trigger as the first step. You can see an example of a WooCommerce HTTP webhook trigger used in a workflow in this video:
Then you can use the Filter action to exit your workflow early if the order.status does not equal Ready for Pickup.
Then you can use your favorite mail provider like Sendgrid, MailChimp, MailerLite, etc to send the email to your customer from the order.
Here’s a video that features both the Filter and email actions:
@pierce thank you so much for the reply and details. I’m off and running already and have sent a couple test emails that are work exactly as I was hoping!!
Do you have a video for taking a JSON array from the HTTP responce and building it into a table? I have an array of items in steps.trigger.event.body.data.object.items.data I’d like to format aa a table.
Hi @pierce once again thanks for the reply and suggestion on speed run.
Here is what my current workflow is doing.
I send pipedream a webhook with a JSON order object
Look for the Status “Ready to Pickup” with a filter. If not found exit.
Get Record from Data Store.
Filter if no record found continue, else exit.
Add Record to data store.
Using Postmark creating an email using the HTML body to create an email that looks like our system emails that send out so it’s constant with my site.
It looks great but I’d like to add the item rows in a table of the body. So between steps 5 and 6 I’d need to create a variable comprised of the headers and items to use in the email body as a table.
Use Postmark templates to move the HTML generation out of Pipedream and into Postmark, so you don’t have to worry about making HTML inside of a code step. But seeing that we’re missing the Send an email with a template action, I don’t think that’s going this is going to be an easy way unfortunately.
Add a Node.js code step that will generate an HTML table with that data, so then it’s easier to inject that table into your HTML body in the Postmark step:
// Generate a 2 column HTML table with a Node.js step
export default defineComponent({
props: {
rows: {
type: 'string[]',
label: "Rows",
description: "Create an HTML table with the rows given (columns separated by commas)"
}
},
async run({ steps, $ }) {
const rows = this.rows.map(row => {
const [one, two] = row.split(',').map(value => `<td>${value}</td>`);
return `<tr>${one}${two}</tr>`;
});
return `
<table>
${rows}
</table>
`
},
})
Copy and paste this into a Node.js step and then click “Refresh Fields”.
Now you can enter in your rows separated by commas like so:
I’ll see if I can get somewhere with it. Seems to only be giving me row [0] in the table and getting a bunch of , at the top of the table. I’m not familiar with this language so it’s all new to me.
Under the hood, it’s just Javascript powering the inputs in the double brackets {{ }} in the props field inputs.
I think the extra commas are due to a formatting issue on your Node.js step. Could you share the exact inputs of the Node.js step that creates the HTML table?
The component I designed assumed you would only insert 2 columns per row maximum, there may be more than that provided.
Hi @pierce, sure thing. It does appear the number of commas is relevant to the number of fields added to make up the table. When only 2 fields are used I renders 1 comma.
I’ve been reading through every article in the community on “looping” and or “iterating” and it’s not looking like there is a clear way to do it yet unless I’m reading this wrong. Loops in workflows · Issue #193 · PipedreamHQ/pipedream · GitHub Based on the last reply here it looks like it’s on the backlog for 2022. I know enough about coding to get in trouble. Thanks again for all of your help.