Created
July 23, 2018 21:28
-
-
Save bumbu/640448f98bd00d4d33a8a45afc5f6737 to your computer and use it in GitHub Desktop.
Microsoft flow for Todoist with dependent tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion":"1.0.0.0", | |
"parameters":{ | |
"logicAppName":{ | |
"type":"String", | |
"metadata":{ | |
"description":"Name of the logic app." | |
} | |
}, | |
"logicAppLocation":{ | |
"defaultValue":"[resourceGroup().location]", | |
"allowedValues":[ | |
"eastasia", | |
"southeastasia", | |
"centralus", | |
"eastus", | |
"eastus2", | |
"westus", | |
"northcentralus", | |
"southcentralus", | |
"northeurope", | |
"westeurope", | |
"japanwest", | |
"japaneast", | |
"brazilsouth", | |
"australiaeast", | |
"australiasoutheast", | |
"southindia", | |
"centralindia", | |
"westindia", | |
"canadacentral", | |
"canadaeast", | |
"westcentralus", | |
"westus2", | |
"[resourceGroup().location]" | |
], | |
"type":"String", | |
"metadata":{ | |
"description":"Location of the logic app." | |
} | |
}, | |
"todoist_Connection_Name":{ | |
"defaultValue":"todoist", | |
"type":"String", | |
"metadata":{ | |
"description":"Name of the connection." | |
} | |
} | |
}, | |
"resources":[ | |
{ | |
"type":"Microsoft.Logic/workflows", | |
"name":"[parameters('logicAppName')]", | |
"apiVersion":"2016-06-01", | |
"location":"[parameters('logicAppLocation')]", | |
"properties":{ | |
"state":"Disabled", | |
"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" | |
}, | |
"$authentication":{ | |
"defaultValue":{ | |
}, | |
"type":"SecureObject" | |
} | |
}, | |
"triggers":{ | |
"When_a_task_is_completed":{ | |
"recurrence":{ | |
"interval":15, | |
"frequency":"Minute" | |
}, | |
"splitOn":"@triggerBody()?['items']", | |
"metadata":{ | |
"flowSystemMetadata":{ | |
"swaggerOperationId":"OnItemCompleted" | |
} | |
}, | |
"type":"ApiConnection", | |
"inputs":{ | |
"host":{ | |
"connection":{ | |
"name":"@parameters('$connections')['todoist']['connectionId']" | |
} | |
}, | |
"method":"get", | |
"path":"/trigger/completed/get_all", | |
"queries":{ | |
"project_id":"all" | |
}, | |
"authentication":"@parameters('$authentication')" | |
} | |
} | |
}, | |
"actions":{ | |
"Parse_JSON":{ | |
"runAfter":{ | |
}, | |
"type":"ParseJson", | |
"inputs":{ | |
"content":"@triggerBody()", | |
"schema":{ | |
"type":"object", | |
"properties":{ | |
"content":{ | |
"type":"string" | |
}, | |
"meta_data":{ | |
}, | |
"user_id":{ | |
"type":"number" | |
}, | |
"task_id":{ | |
"type":"number" | |
}, | |
"project_id":{ | |
"type":"string" | |
}, | |
"completed_date":{ | |
"type":"string" | |
}, | |
"id":{ | |
"type":"string" | |
} | |
} | |
} | |
} | |
}, | |
"Initialize_variable":{ | |
"runAfter":{ | |
"Parse_JSON":[ | |
"Succeeded" | |
] | |
}, | |
"type":"InitializeVariable", | |
"inputs":{ | |
"variables":[ | |
{ | |
"name":"taskName", | |
"type":"String", | |
"value":"@body('Parse_JSON')?['content']" | |
} | |
] | |
} | |
}, | |
"Condition":{ | |
"actions":{ | |
"Set_variable":{ | |
"runAfter":{ | |
"Set_variable_2":[ | |
"Succeeded" | |
] | |
}, | |
"type":"SetVariable", | |
"inputs":{ | |
"name":"nextTaskID", | |
"value":"@{substring(variables('taskName'), variables('idIndex'), sub(length(variables('taskName')), variables('idIndex')))}" | |
} | |
}, | |
"Set_variable_2":{ | |
"runAfter":{ | |
}, | |
"type":"SetVariable", | |
"inputs":{ | |
"name":"idIndex", | |
"value":"@add(2, indexOf(variables('taskName'), '->'))" | |
} | |
}, | |
"Update_a_task":{ | |
"runAfter":{ | |
"Set_variable":[ | |
"Succeeded" | |
] | |
}, | |
"metadata":{ | |
"flowSystemMetadata":{ | |
"swaggerOperationId":"UpdateItem" | |
} | |
}, | |
"type":"ApiConnection", | |
"inputs":{ | |
"host":{ | |
"connection":{ | |
"name":"@parameters('$connections')['todoist']['connectionId']" | |
} | |
}, | |
"method":"post", | |
"body":{ | |
"priority":"2" | |
}, | |
"path":"/sync/updateItem", | |
"queries":{ | |
"id":"@body('Parse_JSON')?['project_id']", | |
"item_id":"@variables('nextTaskID')" | |
}, | |
"authentication":"@parameters('$authentication')" | |
} | |
} | |
}, | |
"runAfter":{ | |
"Initialize_variable_3":[ | |
"Succeeded" | |
] | |
}, | |
"expression":"@contains(variables('taskName'), '->')", | |
"type":"If" | |
}, | |
"Initialize_variable_2":{ | |
"runAfter":{ | |
"Initialize_variable":[ | |
"Succeeded" | |
] | |
}, | |
"type":"InitializeVariable", | |
"inputs":{ | |
"variables":[ | |
{ | |
"name":"nextTaskID", | |
"type":"String", | |
"value":"''" | |
} | |
] | |
} | |
}, | |
"Initialize_variable_3":{ | |
"runAfter":{ | |
"Initialize_variable_2":[ | |
"Succeeded" | |
] | |
}, | |
"type":"InitializeVariable", | |
"inputs":{ | |
"variables":[ | |
{ | |
"name":"idIndex", | |
"type":"Integer", | |
"value":0 | |
} | |
] | |
} | |
} | |
}, | |
"outputs":{ | |
} | |
}, | |
"parameters":{ | |
"$connections":{ | |
"value":{ | |
"todoist":{ | |
"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'todoist')]", | |
"connectionId":"[resourceId('Microsoft.Web/connections', parameters('todoist_Connection_Name'))]", | |
"connectionName":"[parameters('todoist_Connection_Name')]" | |
} | |
} | |
} | |
}, | |
"runtimeConfiguration":{ | |
"collections":{ | |
"maximumItemCount":5000 | |
}, | |
"performanceProfile":{ | |
"throttles":{ | |
"mode":"Low" | |
} | |
} | |
} | |
}, | |
"dependsOn":[ | |
"[resourceId('Microsoft.Web/connections', parameters('todoist_Connection_Name'))]" | |
] | |
}, | |
{ | |
"type":"Microsoft.Web/connections", | |
"name":"[parameters('todoist_Connection_Name')]", | |
"apiVersion":"2016-06-01", | |
"location":"[parameters('logicAppLocation')]", | |
"properties":{ | |
"api":{ | |
"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'todoist')]" | |
}, | |
"displayName":"[parameters('todoist_Connection_Name')]" | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment