User Tools

Site Tools


wiki:ai:azure_chatbot_with_open_ai_and_slack_integration_2
Draft Newest approved | Approver: @ai-us-principals

This is an old revision of the document!


Azure chatbot with open AI and slack integration 2

This document will give the high level steps to deploy an application that uses OpenAI for a chatbot and Azure Bot to integrate into a Slack channel. This Wiki details an alternative way to integrate an Azure chatbot with Slack.

First, you will need to deploy the following infrastructure in Azure:

  1. Azure OpenAI
    1. Once created, go into the Foundry portal and select Create New Deployment from a Base Model. This example uses a gpt-4.1 model with a deployment name of gpt-4.1
    2. After creating the deployment, go to Deployments on the left pane of the Foundry and select your deployment. Take note of the Target URI, Key, and Deployment Name. These values will be used later
    3. In AI Foundry, select Home from the left pane. Take note of the Azure OpenAI endpoint, this will also be used later. It should be in the following format: https://[app-name].openai.azure.com/
  2. Azure Bot
    1. The bot should be deployed as a single tenant bot
    2. In Configuration on the left pane, take note of the Microsoft App ID and App Tenant ID. Then click Manage Password to be taken to the client secrets page of the app registration. Create a new client secret and take note of the value, as it will be inaccessible after leaving this page. If you leave the page and forget to note down the value, just create a new secret.
  3. App Service Plan
    1. Nothing specific needs to be configured for this, but it is needed to deploy the App Service
  4. App Service
    1. This example uses a Linux app with a runtime stack of Python 3.10. I'm not sure if it's accurate, but according to Copilot Python 3.13 is not supported at the time of writing this document.
    2. Select Environment variables in the left pane and create the following environment variables:
      1. MicrosoftAppId: The App (Client) ID from the Azure Bot / App Registration
      2. MicrosoftAppPassword: The client secret that was created in the Azure Bot's app registration
      3. MicrosoftTenantId: The Tenant ID that was copied in the Azure Bot configuration
      4. OPENAI_API_KEY: The Key saved from the OpenAI deployment
      5. OPENAI_DEPLOYMENT: The name of the OpenAI deployment. By default it will be the same as the model name (gpt-4.1 in this example)
      6. OPENAI_ENDPOINT: The openai.azure.com endpoint you saved from AI Foundry. Make sure to remove the trailing slash (i.e. it should end in openai.azure.com, not openai.azure.com/)
    3. Select Configuration from the left pane. Ensure that the stack settings are set to Python 3.10, and that the startup command is “bash startup.txt”. Then scroll down and ensure that “Always on” is set to On
    4. If you did not enable Application Insights during deployment, scroll down to Application Insights on the left pane and Enable it
    5. Select App Service Logs on the left pane and set it to File System
  5. Key Vault (not used in this walkthrough, but highly recommended for additional security)


Azure Bot and Slack App

  1. Go to https://api.slack.com/ and create a new app. Since there are restrictions on adding bots to CDW's Slack workspace, you will likely need to create your own personal workspace first using a free trial
  2. Once the app is created, note down the Client ID, Client Secret, and Signing Secret
  3. Return to your Azure Bot and go to Channels on the left pane. Select Slack from the list of Available Channels and fill in the information you saved from the Slack app. Also copy the two URLs the Bot gives you. The should be https://slack.botframework.com and https://slack.botframework.com/api/Events/[your-bot-name]
  4. Apply the changes to add the Slack channel to your bot. We will come back here later for troubleshooting and validation
  5. Return to your Slack app and make the following changes:
    1. In the App Home tab, scroll down and ensure “Messages Tab” is enabled, along with the checkbox for “Allow users to send Slash commands and messages from the messages tab”
    2. In the OAuth & Permissions tab, add the Redirect URL provided by the Azure Bot to the Redirect URLs section (should be https://slack.botframework.com)
    3. Also in the OAuth & Permissions tab, add the following scopes:
      1. app_mentions:read
      2. channels:history
      3. chat:write
      4. im:history
    4. In the Event Subscriptions tab, click the button to Enable Events, and paste the Request URL given by the Azure Bot (should be https://slack.botframework.com/api/Events/[your-bot-name])
    5. Also in the Event Subscriptions tab, expand the Subscribe to bot events section and add app_mention, message.channels, and message.im
wiki/ai/azure_chatbot_with_open_ai_and_slack_integration_2.1752779353.txt.gz · Last modified: by zhein