{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "connections_salesforce_name": { "defaultValue": "Salesforce", "type": "String" }, "workflows_SalesforceNewCase_name": { "defaultValue": "SalesforceNewCase", "type": "String" }, "workflows_SalesforceNewLead_name": { "defaultValue": "SalesforceNewLead", "type": "String" }, "workflows_PuzzelSalesforceConBase_name": { "defaultValue": "PuzzelSalesforceConBase", "type": "String" }, "PuzzelCustomerKey": { "type": "String", "metadata": { "description": "The Customer key in Puzzel." } }, "PuzzelPassword": { "type": "securestring", "metadata": { "description": "The Password for Puzzel user." } }, "PuzzelUser": { "type": "String", "metadata": { "description": "The Puzzel User." } }, "PuzzelAccessPoint": { "type": "String", "metadata": { "description": "The Access Point(Email address) in Puzzel." } } }, "variables": {}, "resources": [ { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_PuzzelSalesforceConBase_name')]", "location": "[resourceGroup().location]", "properties": { "state": "Enabled", "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "actions": { "Puzzel_auth": { "type": "Http", "inputs": { "method": "POST", "uri": "@parameters('PuzzelAuthURL')", "body": { "customerKey": "@{parameters('PuzzelCustomerKey')}", "password": "@{parameters('PuzzelPassword')}", "userName": "@{parameters('PuzzelUser')}" } }, "runAfter": {}, "runtimeConfiguration": { "secureData": { "properties": [ "inputs" ] } } }, "Puzzel_auth_JSON": { "type": "ParseJson", "inputs": { "content": "@body('Puzzel_auth')", "schema": { "properties": { "accessToken": { "type": "string" }, "twoFactorRequired": { "type": "boolean" } }, "type": "object" } }, "runAfter": { "Puzzel_auth": [ "Succeeded" ] } }, "Puzzel_eTask": { "type": "Http", "inputs": { "method": "POST", "uri": "@{parameters('PuzzelBaseURL')}customers/@{parameters('PuzzelCustomerKey')}/etasks ", "headers": { "Content-Type": "application/json" }, "body": { "eTask": { "from": "@{triggerBody()?['From']}", "subject": "@{triggerBody()?['Subject']}", "to": "@{parameters('PuzzelAccessPoint')}", "uri": "@{triggerBody()?['EntityId']}:caseid", "variables": [ { "name": "entityId", "value": "@{triggerBody()?['EntityId']}" } ], "vipScore": 10 } }, "authentication": { "type": "Raw", "value": "@concat('Bearer ',body('Puzzel_Auth_JSON')?['accessToken'])" } }, "runAfter": { "Puzzel_auth_JSON": [ "Succeeded" ] } }, "Puzzel_eTask_JSON": { "type": "ParseJson", "inputs": { "content": "@body('Puzzel_eTask')", "schema": { "properties": { "code": { "type": "integer" } }, "type": "object" } }, "runAfter": { "Puzzel_eTask": [ "Succeeded" ] } }, "Response": { "type": "Response", "kind": "Http", "inputs": { "statusCode": "@if(equals(body('Puzzel_eTask_JSON')?['code'],0),'200','500')" }, "runAfter": { "Puzzel_eTask_JSON": [ "Succeeded" ] } } }, "parameters": { "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" }, "PuzzelPassword": { "type": "SecureString" }, "PuzzelUser": { "defaultValue": "[parameters('PuzzelUser')]", "type": "String" } }, "triggers": { "manual": { "type": "Request", "kind": "Http", "inputs": { "schema": { "properties": { "EntityId": { "type": "string" }, "From": { "type": "string" }, "Subject": { "type": "string" } }, "type": "object" } } } }, "contentVersion": "1.0.0.0", "outputs": {} }, "parameters": { "PuzzelPassword": { "value": "[parameters('PuzzelPassword')]" } } }, "tags": { "displayName": "PuzzelSalesforceConBase" } }, { "type": "Microsoft.Web/connections", "apiVersion": "2016-06-01", "name": "[parameters('connections_salesforce_name')]", "location": "[resourceGroup().location]", "properties": { "displayName": "salesforce", "customParameterValues": {}, "api": { "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/salesforce')]" } } }, { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_SalesforceNewCase_name')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Logic/workflows', parameters('workflows_PuzzelSalesforceConBase_name'))]", "[resourceId('Microsoft.Web/connections', parameters('connections_salesforce_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": 15 }, "splitOn": "@triggerBody()?['value']", "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['salesforce']['connectionId']" } }, "method": "get", "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('Case'))}/onnewitems" } } }, "actions": { "PuzzelSalesforceConBase": { "runAfter": {}, "type": "Workflow", "inputs": { "body": { "EntityId": "@triggerBody()?['Id']", "From": "Automation@Puzzel.com", "Subject": "New Case: @{triggerBody()?['Subject']}" }, "host": { "triggerName": "manual", "workflow": { "id": "[resourceId('Microsoft.Logic/workflows', parameters('workflows_PuzzelSalesforceConBase_name'))]" } }, "retryPolicy": { "type": "none" } } } }, "outputs": {} }, "parameters": { "$connections": { "value": { "salesforce": { "connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_salesforce_name'))]", "connectionName": "salesforce", "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/salesforce')]" } } } } }, "tags": { "displayName": "SalesforceNewCase" } }, { "type": "Microsoft.Logic/workflows", "apiVersion": "2017-07-01", "name": "[parameters('workflows_SalesforceNewLead_name')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Logic/workflows', parameters('workflows_PuzzelSalesforceConBase_name'))]", "[resourceId('Microsoft.Web/connections', parameters('connections_salesforce_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": 15 }, "splitOn": "@triggerBody()?['value']", "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['salesforce']['connectionId']" } }, "method": "get", "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('Lead'))}/onnewitems" } } }, "actions": { "PuzzelSalesforceConBase": { "runAfter": {}, "type": "Workflow", "inputs": { "body": { "EntityId": "@triggerBody()?['Id']", "From": "Automation@Puzzel.com", "Subject": "New Lead: @{triggerBody()?['Company']}\n" }, "host": { "triggerName": "manual", "workflow": { "id": "[resourceId('Microsoft.Logic/workflows', parameters('workflows_PuzzelSalesforceConBase_name'))]" } }, "retryPolicy": { "type": "none" } } } }, "outputs": {} }, "parameters": { "$connections": { "value": { "salesforce": { "connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_salesforce_name'))]", "connectionName": "salesforce", "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/',resourceGroup().location,'/managedApis/salesforce')]" } } } } }, "tags": { "displayName": "SalesforceNewLead" } } ] }