{
  "$schema":
    "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webSiteName": {
      "type": "string",
      "minLength": 1
    },
    "botMSAppID": {
      "type": "string",
      "minLength": 1
    },
    "botMSAppPasswd": {
      "type": "string",
      "minLength": 1
    },
    "appInsightsAPIKey": {
      "type": "string",
      "minLength": 1
    }
  },
  "variables": {
      "webSiteName": "[toLower(parameters('webSiteName'))]",
      "appInsightsName": "[concat(variables('webSiteName'), '-insights')]",
      "botTagNamePrefix": "[variables('webSiteName')]"
  },
  "resources": [
    {
      "comments": "Bot Framework registration.",
      "type": "Microsoft.BotService/botServices",
      "name": "[variables('webSiteName')]",
      "apiVersion": "2017-12-01",
      "kind": "bot",
      "sku": { "name": "S1" },
      "location": "global",
      "properties": {
        "name": "[variables('webSiteName')]",
        "displayName": "[variables('webSiteName')]",
        "description": "[concat('Bot Framework registration: ', variables('webSiteName'), 'Bot Registration.')]",
        "iconUrl": "//bot-framework.azureedge.net/bot-icons-v1/bot-framework-default.png",
        "endpoint": "[concat('https://', variables('webSiteName'), '.azurewebsites.net/api/messages')]",
        "enabledChannels": ["webchat", "directline" ],
        "configuredChannels": ["webchat", "directline" ],
        "msaAppId": "[parameters('botMSAppID')]",
        "developerAppInsightKey": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').InstrumentationKey]",
        "developerAppInsightsApiKey": "[parameters('appInsightsAPIKey')]",
        "developerAppInsightsApplicationId": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').AppId]",
        "endpointVersion": "3.0"
      },
      "tags": {
        "Solution": "variables('botTagNamePrefix')",
        "Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
        "Resource": "[concat(variables('botTagNamePrefix'), '-botregistratiom')]"
      }
    }
  ],
  "outputs": {
    "botregistration-tests": {
      "value": "[reference(resourceId('Microsoft.BotService/botServices', variables('webSiteName')), '2017-12-01')]",
      "type" : "object"
    },
    "botregistration-tests2": {
      "value": "[reference(resourceId('Microsoft.BotService/botServices', variables('webSiteName')), '2017-12-01').msaAppId]",
      "type" : "string"
    }
  }
}
