{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "connections_dynamicscrmonline_name": { "defaultValue": "dynamicscrmonline", "type": "String" }, "workflows_DynamicsConnectorBase_name": { "defaultValue": "DynamicsConnectorBase", "type": "String" }, "workflows_DynamicsConnectorEmails_name": { "defaultValue": "DynamicsConnectorEmails", "type": "String" }, "workflows_DynamicsConnectorIncident_name": { "defaultValue": "DynamicsConnectorIncident", "type": "String" }, "DynamicsAppId": { "type": "String", "metadata": { "description": "Dynamics AppId." } }, "DynamicsBaseURL": { "type": "String", "metadata": { "description": "Dynamics Base URL." } }, "PuzzelCustomerKey": { "type": "String", "metadata": { "description": "The Client Id in Puzzel." } }, "PuzzelUser": { "type": "String", "metadata": { "description": "The Puzzel User." } }, "PuzzelPassword": { "type": "SecureString", "metadata": { "description": "The Password for Puzzel user." } }, "PuzzelAccessPoint": { "type": "String", "metadata": { "description": "The Access Point(Email address) in Puzzel." } }, "WidgetURI": { "type": "String", "metadata": { "description": "Widget URI" } } }, "variables": {}, "resources": [ { "type": "Microsoft.Web/connections", "apiVersion": "2016-06-01", "name": "[parameters('connections_dynamicscrmonline_name')]", "location": "[resourceGroup().location]", "properties": { "displayName": "[parameters('connections_dynamicscrmonline_name')]", "customParameterValues": {}, "api": { "id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/', parameters('connections_dynamicscrmonline_name'))]" } } }, { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_DynamicsConnectorBase_name')]", "location": "[resourceGroup().location]", "dependsOn": [], "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" }, "DynamicsAppId": { "defaultValue": "[parameters('DynamicsAppId')]", "type": "String" }, "DynamicsBaseURL": { "defaultValue": "[parameters('DynamicsBaseURL')]", "type": "String" }, "PuzzelAccessPoint": { "defaultValue": "[parameters('PuzzelAccessPoint')]", "type": "String" }, "PuzzelAuthURL": { "defaultValue": "https://auth.puzzel.com/api/Authenticate/LogIn", "type": "String" }, "PuzzelBaseURL": { "defaultValue": "https://api.puzzel.com/contactcentre5/", "type": "String" }, "PuzzelCustomerKey": { "defaultValue": "[parameters('PuzzelCustomerKey')]", "type": "String" }, "PuzzelUser": { "defaultValue": "[parameters('PuzzelUser')]", "type": "String" }, "PuzzelPassword": { "type": "SecureString" }, "WidgetURI": { "defaultValue": "[parameters('WidgetURI')]", "type": "String" } }, "triggers": { "manual": { "type": "Request", "kind": "Http", "inputs": { "schema": { "properties": { "EntityId": { "type": "string" }, "From": { "type": "string" }, "Subject": { "type": "string" }, "entityType": { "type": "string" } }, "type": "object" } } } }, "actions": { "Puzzel_auth": { "runAfter": {}, "type": "Http", "inputs": { "body": { "customerKey": "@{parameters('PuzzelCustomerKey')}", "password": "@{parameters('PuzzelPassword')}", "userName": "@{parameters('PuzzelUser')}" }, "method": "POST", "uri": "@parameters('PuzzelAuthURL')" }, "runtimeConfiguration": { "secureData": { "properties": [ "inputs" ] } } }, "Puzzel_auth_JSON": { "runAfter": { "Puzzel_auth": [ "Succeeded" ] }, "type": "ParseJson", "inputs": { "content": "@body('Puzzel_auth')", "schema": { "properties": { "accessToken": { "type": "string" }, "twoFactorRequired": { "type": "boolean" } }, "type": "object" } } }, "Puzzel_eTask": { "runAfter": { "Puzzel_auth_JSON": [ "Succeeded" ] }, "type": "Http", "inputs": { "authentication": { "type": "Raw", "value": "@concat('Bearer ',body('Puzzel_Auth_JSON')?['accessToken'])" }, "body": { "eTask": { "from": "@{triggerBody()?['From']}", "subject": "@{triggerBody()?['Subject']}", "to": "@{parameters('PuzzelAccessPoint')}", "uri": "@{parameters('WidgetURI')}", "variables": [ { "name": "entityType", "value": "@{triggerBody()?['entityType']}" }, { "name": "entityId", "value": "@{triggerBody()?['EntityId']}" }, { "name": "logActivity", "value": "true" }, { "name": "frameUri", "value": "@{parameters('DynamicsBaseURL')}?appid=@{parameters('DynamicsAppId')}+&pagetype=entityrecord&etn=@{triggerBody()?['entityType']}&id=@{triggerBody()?['EntityId']}" } ], "vipScore": 10 } }, "headers": { "Content-Type": "application/json" }, "method": "POST", "uri": "@{parameters('PuzzelBaseURL')}customers/@{parameters('PuzzelCustomerKey')}/etasks " } }, "Puzzel_eTask_JSON": { "runAfter": { "Puzzel_eTask": [ "Succeeded" ] }, "type": "ParseJson", "inputs": { "content": "@body('Puzzel_eTask')", "schema": { "properties": { "code": { "type": "integer" } }, "type": "object" } } }, "Response": { "runAfter": { "Puzzel_eTask_JSON": [ "Succeeded" ] }, "type": "Response", "kind": "Http", "inputs": { "statusCode": "@if(equals(body('Puzzel_eTask_JSON')?['code'],0),'200','500')" } } }, "outputs": {} }, "parameters": { "PuzzelPassword": { "value": "[parameters('PuzzelPassword')]" } } } }, { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_DynamicsConnectorEmails_name')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Logic/workflows', parameters('workflows_DynamicsConnectorBase_name'))]", "[resourceId('Microsoft.Web/connections', parameters('connections_dynamicscrmonline_name'))]" ], "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" } }, "triggers": { "When_a_record_is_created": { "recurrence": { "frequency": "Minute", "interval": 1 }, "splitOn": "@triggerBody()?['value']", "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['dynamicscrmonline']['connectionId']" } }, "method": "get", "path": "/v2/datasets//tables/@{encodeURIComponent(encodeURIComponent('emails'))}/onnewitems" } } }, "actions": { "DynamicsConnectorBase": { "runAfter": {}, "type": "Workflow", "inputs": { "body": { "EntityId": "@triggerBody()?['activityid']", "From": "@triggerBody()?['sender']", "Subject": "@triggerBody()?['subject']", "entityType": "email" }, "host": { "triggerName": "manual", "workflow": { "id": "[resourceId('Microsoft.Logic/workflows', parameters('workflows_DynamicsConnectorBase_name'))]" } } } } }, "outputs": {} }, "parameters": { "$connections": { "value": { "dynamicscrmonline": { "connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_dynamicscrmonline_name'))]", "connectionName": "dynamicscrmonline", "id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/', parameters('connections_dynamicscrmonline_name'))]" } } } } } }, { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_DynamicsConnectorIncident_name')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Logic/workflows', parameters('workflows_DynamicsConnectorBase_name'))]", "[resourceId('Microsoft.Web/connections', parameters('connections_dynamicscrmonline_name'))]" ], "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" } }, "triggers": { "When_a_record_is_created": { "recurrence": { "frequency": "Minute", "interval": 1 }, "splitOn": "@triggerBody()?['value']", "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['dynamicscrmonline']['connectionId']" } }, "method": "get", "path": "/v2/datasets//tables/@{encodeURIComponent(encodeURIComponent('incidents'))}/onnewitems" } } }, "actions": { "DynamicsConnectorBase": { "runAfter": {}, "type": "Workflow", "inputs": { "body": { "EntityId": "@triggerBody()?['incidentid']", "From": "dynamics@puzzel.com", "Subject": "@{triggerBody()?['title']}", "entityType": "incident" }, "host": { "triggerName": "manual", "workflow": { "id": "[resourceId('Microsoft.Logic/workflows', parameters('workflows_DynamicsConnectorBase_name'))]" } }, "retryPolicy": { "type": "none" } } } }, "outputs": {} }, "parameters": { "$connections": { "value": { "dynamicscrmonline": { "connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_dynamicscrmonline_name'))]", "connectionName": "dynamicscrmonline", "id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/', parameters('connections_dynamicscrmonline_name'))]" } } } } } } ] }