{"flow":{"id":49,"summary":"Refund manager with approval step - Automatically triggered by email reception","versions":[188,189,212],"created_by":"henri186","created_at":"2023-06-23T12:56:37.344Z","votes":0,"approved":false,"apps":["slack","mailchimp"],"value":{"modules":[{"id":"a","value":{"lock":"{\n  \"dependencies\": {}\n}\n//bun.lockb\n<empty>","type":"rawscript","content":"// import * as wmill from \"windmill-client\"\n\nexport async function main(x: any) {\n  return JSON.parse(x)\n}\n","language":"bun","is_trigger":false,"input_transforms":{"x":{"expr":"flow_input.mandrill_events","type":"javascript"}}}},{"id":"b","value":{"path":"hub/11500/slack/request_interactive_slack_approval","type":"script","is_trigger":false,"input_transforms":{"message":{"expr":"`New email from _${results.a[0].msg.from_email}_ recieved on _${results.a[0].msg.headers.Date}_. \\n Subject: ${results.a[0].msg.headers.Subject} \\n Content: \\n ${results.a[0].msg.text}`","type":"javascript"},"approver":{"type":"static","value":""},"channelId":{"type":"static","value":"customers"},"defaultArgsJson":{"type":"static","value":null},"dynamicEnumsJson":{"type":"static","value":null},"slackResourcePath":{"type":"static","value":"u/alex/docu_slack"}}},"summary":"Request Interactive Slack Approval (slack)","suspend":{"timeout":1800,"hide_cancel":false,"resume_form":{"schema":{"order":["Action","Message"],"required":["Action","Message"],"properties":{"Action":{"enum":["Refund","Do not refund","Email"],"type":"string","default":"","nullable":false,"enumLabels":{},"description":""},"Message":{"type":"string","default":"","nullable":false,"description":""}}}},"required_events":1},"continue_on_error":false},{"id":"r","value":{"lock":"{\n  \"dependencies\": {}\n}\n//bun.lockb\n<empty>","type":"rawscript","content":"// import * as wmill from \"windmill-client\"\n\nexport async function main(x: any) {\n  return x\n}\n","language":"bun","is_trigger":false,"input_transforms":{"x":{"expr":"resume","type":"javascript"}}},"summary":"Receive Resume Form"},{"id":"c","value":{"type":"branchone","default":[{"id":"n","value":{"path":"hub/849/slack/send_message_to_channel","type":"script","input_transforms":{"text":{"expr":"`Refund request by ${results.a[0].msg.from_email}. Manage refund manually.`","type":"javascript"},"slack":{"expr":"flow_input[\"Slack Account\"]","type":"javascript"},"channel":{"expr":"flow_input[\"Slack Channel\"]","type":"javascript"}}},"summary":"Send Message to Channel (slack)"}],"branches":[{"expr":"results.r[\"Action\"] === \"Email\"","modules":[{"id":"o","value":{"path":"hub/868/gmail/_send_email","type":"script","input_transforms":{"message":{"expr":"results.r[\"Message\"]","type":"javascript"},"subject":{"type":"static","value":"More information"},"user_id":{"type":"static","value":"me"},"to_email":{"expr":"results.a[0].msg.from_email","type":"javascript"},"gmail_auth":{"expr":"flow_input[\"Gmail Account\"]","type":"javascript"}}},"summary":" Send Email (gmail)"},{"id":"l","value":{"path":"hub/849/slack/send_message_to_channel","type":"script","input_transforms":{"text":{"expr":"`Refund request by ${results.a[0].msg.from_email}. Message ${resume[\"Message\"]} was just sent.`","type":"javascript"},"slack":{"expr":"flow_input[\"Slack Account\"]","type":"javascript"},"channel":{"expr":"flow_input[\"Slack Channel\"]","type":"javascript"}}},"summary":"Send Message to Channel (slack)"}],"summary":"Send message","parallel":true,"skip_failure":true},{"expr":"results.r[\"Action\"] === \"Do not refund\"","modules":[{"id":"h","value":{"lock":"","type":"rawscript","content":"export async function main() {\n   console.log(\"Your database logic here\")\n}","language":"deno","input_transforms":{}},"summary":"Update database"},{"id":"i","value":{"path":"hub/868/gmail/_send_email","type":"script","input_transforms":{"message":{"expr":"`Hello! \\nThank you for your message. \\nAfter a review from our team, we decided you can not be refunded this article.`","type":"javascript"},"subject":{"type":"static","value":"Refund request"},"user_id":{"type":"static","value":"me"},"to_email":{"expr":"results.a[0].msg.from_email","type":"javascript"},"gmail_auth":{"expr":"flow_input[\"Gmail Account\"]","type":"javascript"}}},"summary":" Send Email (gmail)"},{"id":"j","value":{"path":"hub/849/slack/send_message_to_channel","type":"script","input_transforms":{"text":{"expr":"`User ${results.a[0].msg.from_email} was just been refused refund`","type":"javascript"},"slack":{"expr":"flow_input[\"Slack Account\"]","type":"javascript"},"channel":{"expr":"flow_input[\"Slack Channel\"]","type":"javascript"}}},"summary":"Send Message to Channel (slack)"}],"summary":"Do not refund","parallel":true,"skip_failure":true},{"expr":"results.r[\"Action\"] === \"Refund\"","modules":[{"id":"d","value":{"lock":"","type":"rawscript","content":"export async function main() {\n   console.log(\"Your Stripe logic here\")\n}","language":"deno","input_transforms":{}},"summary":"Refund via Stripe"},{"id":"f","value":{"lock":"","type":"rawscript","content":"export async function main() {\n   console.log(\"Your database logic here\")\n}","language":"deno","input_transforms":{}},"summary":"Update database"},{"id":"m","value":{"path":"hub/868/gmail/_send_email","type":"script","input_transforms":{"message":{"expr":"`Hi! \\nThank you for your message. \\nYou have just been refunded :)`","type":"javascript"},"subject":{"type":"static","value":"Refund"},"user_id":{"type":"static","value":"me"},"to_email":{"expr":"results.a[0].msg.from_email","type":"javascript"},"gmail_auth":{"expr":"flow_input[\"Gmail Account\"]","type":"javascript"}}},"summary":" Send Email (gmail)"},{"id":"g","value":{"path":"hub/849/slack/send_message_to_channel","type":"script","input_transforms":{"text":{"expr":"`User ${results.a[0].msg.from_email} has just been refunded`","type":"javascript"},"slack":{"expr":"flow_input[\"Slack Account\"]","type":"javascript"},"channel":{"expr":"flow_input[\"Slack Channel\"]","type":"javascript"}}},"summary":"Send Message to Channel (slack)"}],"summary":"Refund","parallel":true,"skip_failure":true}]},"summary":""}]},"schema":{"type":"object","order":["Gmail Account","Slack Account","Slack Channel","mandrill_events"],"$schema":"https://json-schema.org/draft/2020-12/schema","required":[],"properties":{"Gmail Account":{"type":"object","format":"resource-gmail","description":"https://docs.windmill.dev/docs/integrations/gmail"},"Slack Account":{"type":"object","format":"resource-slack","description":"https://docs.windmill.dev/docs/integrations/slack"},"Slack Channel":{"type":"string","format":null,"default":"general","description":"Channel to send Slack alerts"},"mandrill_events":{"type":"string","format":"","default":"","description":""}}},"description":"To configure trigger by email reception: https://docs.windmill.dev/docs/integrations/mailchimp_mandrill","recording":null,"vcreated_at":"2025-01-06T21:44:09.579Z","vcreated_by":"alex308","comments":[]}}