{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "workflows_DocentricProjects_NotifyInMSTeamsChannel_WhenFileCreatedInSharePoint_name": { "defaultValue": "DocentricProjects_NotifyInMSTeamsChannel_WhenFileCreatedInSharePoint", "type": "String" }, "connections_sharepointonline_1_externalid": { "defaultValue": "/subscriptions/{my subscription guid - 2f0bad66-b6e9-4c5f-bfdb-fddf9ee3e0f6}/resourceGroups/{my resource group}/providers/Microsoft.Web/connections/sharepointonline-1", "type": "String" }, "connections_teams_externalid": { "defaultValue": "/subscriptions/{my subscription guid - 2f0bad66-b6e9-4c5f-bfdb-fddf9ee3e0f6}/resourceGroups/{my resource group}/providers/Microsoft.Web/connections/teams", "type": "String" } }, "variables": {}, "resources": [ { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_DocentricProjects_NotifyInMSTeamsChannel_WhenFileCreatedInSharePoint_name')]", "location": "westus2", "properties": { "state": "Enabled", "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "contentVersion": "1.0.0.0", "parameters": { "$connections": { "defaultValue": {}, "type": "Object" }, "DocentricProjectSite": { "defaultValue": "https://docentric.sharepoint.com/sites/DocentricProjects", "type": "String" } }, "triggers": { "When_a_file_is_created_(properties_only)_in_a_document_library": { "recurrence": { "frequency": "Minute", "interval": 3 }, "splitOn": "@triggerBody()?['value']", "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['sharepointonline_1']['connectionId']" } }, "method": "get", "path": "/datasets/@{encodeURIComponent(encodeURIComponent(parameters('DocentricProjectSite')))}/tables/@{encodeURIComponent(encodeURIComponent('7e5ba17e-5a70-416a-9358-8d476c446493'))}/onnewfileitems" } } }, "actions": { "Condition_-_If_ChannelID_is_found_then_we_send_a_notification,_else_we_terminate": { "actions": {}, "runAfter": { "For_each_-_Read_the_Channel_ID_if_the_filter_before_found_any_items": [ "Succeeded" ] }, "else": { "actions": { "Terminate_-_Channel_has_not_been_found": { "runAfter": {}, "type": "Terminate", "inputs": { "runStatus": "Cancelled" } } } }, "expression": { "and": [ { "not": { "equals": [ "@variables('ChannelID')", "" ] } } ] }, "type": "If" }, "Filter_array_-_Find_the_correct_Channel_in_a_Team": { "runAfter": { "List_channels": [ "Succeeded" ] }, "type": "Query", "inputs": { "from": "@body('List_channels')?['value']", "where": "@equals(item()?['displayName'], variables('ChannelName'))" } }, "For_each_-_Read_the_Channel_ID_if_the_filter_before_found_any_items": { "foreach": "@body('Filter_array_-_Find_the_correct_Channel_in_a_Team')", "actions": { "Set_variable": { "runAfter": {}, "type": "SetVariable", "inputs": { "name": "ChannelID", "value": "@items('For_each_-_Read_the_Channel_ID_if_the_filter_before_found_any_items')?['id']" } } }, "runAfter": { "Filter_array_-_Find_the_correct_Channel_in_a_Team": [ "Succeeded" ] }, "type": "Foreach" }, "Initialize_variable_ChannelID_with_an_empty_string": { "runAfter": { "Initialize_variable_ChannelName_from_the_newly_added_file_path": [ "Succeeded" ] }, "type": "InitializeVariable", "inputs": { "variables": [ { "name": "ChannelID", "type": "string" } ] } }, "Initialize_variable_ChannelName_from_the_newly_added_file_path": { "runAfter": {}, "type": "InitializeVariable", "inputs": { "variables": [ { "name": "ChannelName", "type": "string", "value": "@{split(triggerBody()?['{Path}'], '/')[1]}" } ] } }, "List_channels": { "runAfter": { "Initialize_variable_ChannelID_with_an_empty_string": [ "Succeeded" ] }, "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['teams']['connectionId']" } }, "method": "get", "path": "/beta/groups/@{encodeURIComponent('56665eb6-3851-4fec-9344-fd0750df2271')}/channels" } }, "Post_a_message_(V3)_to_the_correct_team_Channel": { "runAfter": { "Condition_-_If_ChannelID_is_found_then_we_send_a_notification,_else_we_terminate": [ "Succeeded" ] }, "type": "ApiConnection", "inputs": { "body": { "body": { "content": "
Hey there,
\n
\nI have added a new project file @{concat('', triggerBody()?['{FilenameWithExtension}'], '')} here @{concat('', replace(triggerBody()?['{FullPath}'], 'Dokumenti v skupni rabi', 'Documents'), '')}.
\n
\nDocument preview:
\n@{concat('')}
\n
\n
\nCheers,
\n@{triggerBody()?['Author']?['DisplayName']} (@{triggerBody()?['Author']?['Email']})