===
This project implements an experimental chatbot that interacts with Databricks' Genie API. The bot is designed to facilitate conversations with Genie, Databricks' AI assistant, through a chat interface like MS Teams.
This experimental code creates a Genie BOT in Databricks using the Genie API. It's important to note that this is not production-ready code and is not associated with or endorsed by any employer. The code is intended to be used as-is for experimental and learning purposes only.
- Integrates with Databricks' Genie API to start conversations and process follow-up messages
- Handles user queries and presents Genie's responses
- Manages conversation state for multiple users
- Formats and displays query results in a readable markdown table
- Handles clarification requests from Genie
The bot is built using:
- Python
- Bot Framework SDK
- aiohttp for asynchronous HTTP requests
- Databricks Genie Conversation API
The main components of the system are:
- A
GenieQuerierclass that handles the communication with the Genie API - A
GenieResultclass that represents the results returned by Genie - A
AdaptiveCardclass that formats the results into a user-friendly card format - A
MyBotclass that processes incoming messages and manages user conversations - An
aiohttpweb application that serves as the entry point for bot messages
This code is experimental that is not yet supported by Databricks. It should not be used in production environments and is provided strictly for educational and experimental purposes.
The code was tested in Azure Bot Framework that facilitates to integrate with any chatbot like MS Teams.
- Go to
src/const.pyand updateAUTH_METHODto one of eitheroauthorservice_principal.
- Please update spaces.json with your own Genie Space IDs in your workspace.
- Retrieve your Space ID from the Genie Space URL - see docs here
- Python version 3.12
- Install the required dependencies listed in
requirements.txt - Set up the necessary environment variables (
DATABRICKS_SPACE_ID,DATABRICKS_HOST, etc.) in theenv.examplefile, change the name to.env - Run the
app.pyscript to start the bot - Test the bot with Bot Framework Emulator
- Create App Service Plan
- Create Web App on the App Service Plan
- Please use
PYTHON 3.12when you select the python version
- Please use
- Add Configuration to the web app
-
Set startup command to be:
gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 1200 --chdir src app:app -
Set the necessary environment variables for authentication
- Always required:
DATABRICKS_HOST(your Databricks Workspace URL)APP_ID(your Azure Bot's App ID)APP_PASSWORD(your Azure Bot's Secret)
- If you want to use Service Principal Authentication (optional otherwise)
DATABRICKS_CLIENT_IDDATABRICKS_CLIENT_SECRET
- Always required:
-
Set environment variable
SCM_DO_BUILD_DURING_DEPLOYMENTtotrueto ensure the dependencies are installed during deployment.
-
- Create Azure Bot. Add webapp endpoint details to Azure Bot:
<webapp-url>/api/messages- If you're going to use Oauth authentication, please refer to setup instructions
sequenceDiagram
participant User
participant Azure Portal
participant GitHub
participant Azure CLI
participant VSCode
participant Web App
participant Bot Service
participant Databricks
participant Teams
User->>GitHub: Clone DatabricksGenieBOT repository
User->>Azure Portal: Create App Service Plan (Linux)
User->>Azure Portal: Create Web App (Python 3.12)
User->>Azure Portal: Create Azure Bot AI Service
User->>Azure Portal: Configure Bot (Secret, Icon, Description)
User->>Azure Portal: Configure Bot Messaging Endpoint
User->>Azure Portal: Configure Bot Channel (Teams)
User->>Databricks: Curate Genie Space and get Space ID
User->>Databricks: Generate Token
User->>Azure Portal: Configure Web App (Startup Command, Environment Variables)
User->>VSCode: Open project folder
User->>Azure CLI: Install Azure CLI
User->>VSCode: Create and activate virtual environment
User->>VSCode: Install requirements
User->>Azure CLI: Login (az login)
User->>Azure CLI: Deploy Web App (az webapp up)
User->>Azure Portal: Configure Web App settings
User->>Azure Portal: Test Bot in Web Chat
User->>Teams: Test Bot in Microsoft Teams

