{"flow":{"id":58,"summary":"Example handler for Microsoft Teams bot commands","versions":[213],"created_by":"alex308","created_at":"2025-02-06T17:32:03.758Z","votes":0,"approved":true,"apps":["teams"],"value":{"modules":[{"id":"c","value":{"lock":"{\n  \"dependencies\": {}\n}\n//bun.lock\n<empty>","type":"rawscript","content":"interface Output {\n  command: string;\n  input: string;\n}\n\nexport async function main(text_input: string): Promise<Output> {\n  const tokenized: string[] = text_input?.split(' ') || [];\n  const command = tokenized[0] || 'help';\n  const input = tokenized.slice(1,).join(' ');\n\n  return { command, input };\n}","language":"bun","is_trigger":false,"input_transforms":{"text_input":{"expr":"flow_input.command","type":"javascript"}}}},{"id":"d","value":{"type":"branchone","default":[{"id":"e","value":{"type":"rawscript","content":"import * as wmill from \"windmill-client\"\n\nexport async function main(\n  activity_id: string,\n) {\n  await wmill.TeamsService.sendMessageToConversation(\n    {\n      requestBody: {\n        conversation_id: activity_id,\n        success: true,\n        text: getHelp()\n      }\n    }\n  )\n}\n\nfunction getHelp() {\n  const help = `Supported commands\n  help - prints this command\n  echo - prints input\n  `;\n  return help;\n}\n","language":"bun","is_trigger":false,"input_transforms":{"activity_id":{"expr":"`${flow_input.activity_id}`","type":"javascript","value":"${flow_input.activity_id}"}}}}],"branches":[{"expr":"results.c.command === 'echo'","modules":[{"id":"f","value":{"type":"rawscript","content":"import * as wmill from \"windmill-client\"\n\nexport async function main(\n  activity_id: string,\n  command: string,\n  from_name: string,\n) {\n  // Your business logic\n  const res = \"task completed successfully!\"\n\n  // (optional) Send update to Teams channel about completion of job\n  await wmill.TeamsService.sendMessageToConversation(\n    {\n      requestBody: {\n        conversation_id: activity_id,\n        success: true,\n        text: `Hi, ${from_name}, command: ${command} ran successfully with the following result: ${res}`\n      }\n    }\n  )\n}","language":"bun","is_trigger":false,"input_transforms":{"command":{"expr":"flow_input.command","type":"javascript"},"from_name":{"expr":"flow_input.from_name","type":"javascript"},"activity_id":{"expr":"flow_input.activity_id","type":"javascript"}}}}],"summary":"run command","parallel":true,"skip_failure":true}]},"summary":""}]},"schema":{"type":"object","order":["activity_id","command","from_name","team_id","teams_message"],"$schema":"https://json-schema.org/draft/2020-12/schema","required":["activity_id","command","from_name"],"properties":{"command":{"type":"string","default":"","nullable":false,"description":""},"team_id":{"type":"string","default":"","nullable":false,"description":""},"from_name":{"type":"string","default":"","nullable":false,"description":""},"activity_id":{"type":"string","default":"","nullable":false,"description":""},"teams_message":{"type":"string","default":"","nullable":false,"description":""}}},"description":"Microsoft Teams bot will handle\n```console\n/windmill help\n/windmill echo foo bar\n```","recording":null,"vcreated_at":"2025-02-06T17:32:03.758Z","vcreated_by":"alex308","comments":[]}}