{"flow":{"id":14,"summary":"Slack Alert EUR/USD Exchange rate","versions":[29,30,31,106,164,165],"created_by":"fatonramadani","created_at":"2022-08-04T09:07:50.853Z","votes":0,"approved":true,"apps":["slack","exchangerates"],"value":{"modules":[{"id":"a","value":{"type":"rawscript","content":"export async function main(api_key: string, threshold: number) {\n  const myHeaders = new Headers();\n  myHeaders.append(\"apikey\", api_key);\n\n  const requestOptions = {\n    method: \"GET\",\n    headers: myHeaders,\n  };\n\n  const res = await fetch(\n    \"https://api.apilayer.com/exchangerates_data/latest?symbols=USD&base=EUR\",\n    requestOptions,\n  );\n  const text = await res.text();\n\n  if (JSON.parse(text).rates.USD > 1) {\n    return [JSON.parse(text).rates.USD];\n  } else {\n    return [];\n  }\n}\n","language":"deno"},"stop_after_if":{"expr":"result.res1.length == 0","skip_if_stopped":true},"input_transforms":{"api_key":{"expr":"flow_input.api_key","type":"javascript"},"threshold":{"expr":"flow_input.threshold","type":"javascript"}}},{"id":"b","value":{"type":"forloopflow","modules":[{"id":"c","value":{"path":"hub/111/send_message_to_channel","type":"script"},"input_transforms":{"text":{"expr":"import { previous_result, flow_input, step, variable, resource, params } from 'windmill@1'\n\n`Warning: EUR -> USD Rate above threshold: ${previous_result._value}`","type":"javascript"},"slack":{"expr":"import { flow_input } from 'windmill@1'\n\nflow_input.slack","type":"javascript"},"channel":{"expr":"import { previous_result, flow_input, step, variable, resource, params } from 'windmill@1'\n\n`${flow_input.channel}`","type":"javascript"}}}],"iterator":{"expr":"result.res1","type":"javascript"},"skip_failures":true},"input_transforms":{}}]},"schema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["text","api_key","slack","channel"],"properties":{"slack":{"type":"object","format":"resource-slack","description":""},"api_key":{"type":"string","format":"","description":"Exchange Rates Data API"},"channel":{"type":"string","format":"","description":""},"threshold":{"type":"number","format":"","default":1,"description":""}}},"description":"This flow sends a Slack message when the EUR/USD exchange rate is above a threshold.\nThis flow needs an API key from: https://apilayer.com/marketplace/exchangerates_data-api.","recording":null,"vcreated_at":"2023-04-23T10:16:14.214Z","vcreated_by":"rubenfiszel","comments":[]}}