I thought I would share my solution of automatically importing webflow orders into Airtable and Slack through Zapier, as it took me a little to figure out.
The main problem is that Zapier converts the webflow hook data to strings, meaning you can’t manipulate the ‘order’ nested array that the webflow new order hook delivers to Zapier. It requires some not so pretty string manipulation but it works.
Zap flow:
- Weblow, new order
- Run Javascript
- Airtable, new record
The ‘run javascript’ code works as below:
var obj = {};
var order = inputData.order;
var first_pos = order.indexOf("productName") + 13;
var second_pos = order.indexOf("productSlug");
var size = second_pos - first_pos;
var productName = order.substr(first_pos,size);
var first_pos = order.indexOf("'url': '") + 8;
var second_pos = order.indexOf("', 'alt':");
var size = second_pos - first_pos;
var image = order.substr(first_pos,size);
obj.name = inputData.name;
obj.city = inputData.city;
obj.productName = productName.trim();
obj.image = image;
obj.amount = inputData.amount;
return obj;