Example handler for Microsoft Teams bot commands
| 1 | { |
| 2 | "summary": "Example handler for Microsoft Teams bot commands", |
| 3 | "value": { |
| 4 | "modules": [ |
| 5 | { |
| 6 | "id": "c", |
| 7 | "value": { |
| 8 | "lock": "{\n \"dependencies\": {}\n}\n//bun.lock\n<empty>", |
| 9 | "type": "rawscript", |
| 10 | "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}", |
| 11 | "language": "bun", |
| 12 | "is_trigger": false, |
| 13 | "input_transforms": { |
| 14 | "text_input": { |
| 15 | "expr": "flow_input.command", |
| 16 | "type": "javascript" |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | }, |
| 21 | { |
| 22 | "id": "d", |
| 23 | "value": { |
| 24 | "type": "branchone", |
| 25 | "default": [ |
| 26 | { |
| 27 | "id": "e", |
| 28 | "value": { |
| 29 | "type": "rawscript", |
| 30 | "content": "import * as orvanta from \"@orvanta/client\"\n\nexport async function main(\n activity_id: string,\n) {\n await orvanta.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", |
| 31 | "language": "bun", |
| 32 | "is_trigger": false, |
| 33 | "input_transforms": { |
| 34 | "activity_id": { |
| 35 | "expr": "`${flow_input.activity_id}`", |
| 36 | "type": "javascript", |
| 37 | "value": "${flow_input.activity_id}" |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | ], |
| 43 | "branches": [ |
| 44 | { |
| 45 | "expr": "results.c.command === 'echo'", |
| 46 | "modules": [ |
| 47 | { |
| 48 | "id": "f", |
| 49 | "value": { |
| 50 | "type": "rawscript", |
| 51 | "content": "import * as orvanta from \"@orvanta/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 orvanta.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}", |
| 52 | "language": "bun", |
| 53 | "is_trigger": false, |
| 54 | "input_transforms": { |
| 55 | "command": { |
| 56 | "expr": "flow_input.command", |
| 57 | "type": "javascript" |
| 58 | }, |
| 59 | "from_name": { |
| 60 | "expr": "flow_input.from_name", |
| 61 | "type": "javascript" |
| 62 | }, |
| 63 | "activity_id": { |
| 64 | "expr": "flow_input.activity_id", |
| 65 | "type": "javascript" |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | ], |
| 71 | "summary": "run command", |
| 72 | "parallel": true, |
| 73 | "skip_failure": true |
| 74 | } |
| 75 | ] |
| 76 | }, |
| 77 | "summary": "" |
| 78 | } |
| 79 | ] |
| 80 | }, |
| 81 | "description": "Microsoft Teams bot will handle\n```console\n/orvanta help\n/orvanta echo foo bar\n```", |
| 82 | "schema": { |
| 83 | "type": "object", |
| 84 | "order": [ |
| 85 | "activity_id", |
| 86 | "command", |
| 87 | "from_name", |
| 88 | "team_id", |
| 89 | "teams_message" |
| 90 | ], |
| 91 | "$schema": "https://json-schema.org/draft/2020-12/schema", |
| 92 | "required": [ |
| 93 | "activity_id", |
| 94 | "command", |
| 95 | "from_name" |
| 96 | ], |
| 97 | "properties": { |
| 98 | "command": { |
| 99 | "type": "string", |
| 100 | "default": "", |
| 101 | "nullable": false, |
| 102 | "description": "" |
| 103 | }, |
| 104 | "team_id": { |
| 105 | "type": "string", |
| 106 | "default": "", |
| 107 | "nullable": false, |
| 108 | "description": "" |
| 109 | }, |
| 110 | "from_name": { |
| 111 | "type": "string", |
| 112 | "default": "", |
| 113 | "nullable": false, |
| 114 | "description": "" |
| 115 | }, |
| 116 | "activity_id": { |
| 117 | "type": "string", |
| 118 | "default": "", |
| 119 | "nullable": false, |
| 120 | "description": "" |
| 121 | }, |
| 122 | "teams_message": { |
| 123 | "type": "string", |
| 124 | "default": "", |
| 125 | "nullable": false, |
| 126 | "description": "" |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | } |