Skip to content

Latest commit

Β 

History

34 Commits

Folders and files

Repository files navigation

Agentic AI Helpdesk (FastAPI + Azure + M365)

This project is a complete, event-driven, AI-powered helpdesk solution. It uses FastAPI for high-performance ingestion, Azure Service Bus for decoupling, and a Python worker to enrich requests with[...]


View Solution Architecture Flowchart
flowchart LR
  U["User submits Helpdesk Form<br/>(Title, Description, Category, Priority, ActionHint, RequesterEmail)"]
  U --> F[FastAPI /submit handler]

  F --> T["Save entity to<br/>Azure Table Storage<br/>(HelpdeskRequests)"]
  F --> Q[Send compact message<br/>to Service Bus queue 'm365']

  Q --> W[Worker process<br/>listens on 'm365']
  W --> R[Fetch full entity<br/>from Table Storage]

  R --> E["AI Enrichment<br/>(Azure OpenAI)"]
  E -->|enriched title/summary/urgency| TEAMS[Send MessageCard<br/>to Teams via Webhook]

  TEAMS --> A["Agent Framework<br/>decide_action(entity, enriched)"]

  A -->|notify-team| ACS[Send notification email<br/>via Azure Communication Services]
  A -->|create-task| PL[Create Planner task<br/>via Microsoft Graph]
  A -->|create-ticket| FLOW["Trigger Power Automate<br/>HTTP Flow (ticket)"]
  A -->|store-only| END["No further action<br/>(stored + Teams only)"]
Loading
View Screenshots

agentsbusscr1

agentsbusscr2


πŸš€ Features

  • FastAPI Ingestion: A high-performance, asynchronous API endpoint for form submission.
  • Event-Driven: Fully decoupled architecture using Azure Service Bus for resilience.
  • AI Enrichment: Uses Azure OpenAI to summarize, re-title, and assess the urgency of user requests.
  • Agentic Actions: Leverages the Microsoft Agent Framework to intelligently decide the next best action.
  • Analytics Chat: An AI-powered conversational interface to query ticket data (counts by category, priority, recent tickets, etc.).
  • M365 Integration:
    • Posts notifications to Microsoft Teams.
    • Creates tasks in Microsoft Planner via Graph API.
    • Sends notification emails via Azure Communication Services.
    • Triggers Power Automate flows for custom ticketing.

πŸ”§ Prerequisites

Before you begin, you will need:

  • Python 3.10+
  • An Azure Subscription
  • An Azure OpenAI resource with a model deployed (e.g., gpt-4o)
  • A Microsoft 365 Tenant with admin permissions to:
    • Create App Registrations
    • Microsoft Teams (with a channel for notifications)
    • Microsoft Planner (with a plan and bucket)
    • Power Automate
  • An Azure Communication Services resource configured for email.

βš™οΈ Configuration & Setup

1. Local Project Setup

First, clone the repository and set up your Python virtual environment.

# Clone the repository
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

# Create a virtual environment (venv)
python -m venv .venv

# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate

# Install the required packages
pip install -r requirements.txt

2. Create .env File

Create a file named .env in the root of the project. Copy the content below into it.

# Azure Storage
AZURE_TABLE_CONN_STR=
AZURE_TABLE_NAME=HelpdeskRequests

# Azure Service Bus
AZURE_SERVICEBUS_CONN_STR=
AZURE_SERVICEBUS_QUEUE_NAME=m365

# Teams
TEAMS_WEBHOOK_URL=

# Azure OpenAI / Agent Framework
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_DEPLOYMENT=
AZURE_AI_PROJECT_ENDPOINT=
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=

# Email via ACS
ACS_CONNECTION_STRING=
ACS_SENDER_ADDRESS=
NOTIFY_EMAILS=

# Planner via Graph
GRAPH_TENANT_ID=
GRAPH_CLIENT_ID=
GRAPH_CLIENT_SECRET=
PLANNER_PLAN_ID=
PLANNER_BUCKET_ID=

# Power Automate HTTP flow
POWER_AUTOMATE_FLOW_URL=

3. Get Configuration Values

Azure Storage & Service Bus

  1. Azure Storage:

    • Create an Azure Storage Account.
    • Under Access keys, copy the Connection string.
    • Create a table named HelpdeskRequests.
  2. Azure Service Bus:

    • Create a Service Bus Namespace.
    • Copy the Primary Connection String.
    • Create a queue named m365.

Microsoft Teams Webhook

  1. Open Teams β†’ go to the channel.
  2. Select Connectors β†’ Incoming Webhook.
  3. Generate and copy the webhook URL.

Azure OpenAI

  1. Open your Azure OpenAI resource.
  2. Copy the endpoint and key.
  3. Copy your model deployment name.

ACS Email

  1. Create an ACS resource.
  2. Configure Email β†’ verified domain.
  3. Copy connection string + sender address.

Microsoft Graph for Planner

  1. Create an App Registration.
  2. Copy:
    • Tenant ID
    • Client ID
  3. Add Graph API permission:
    • Tasks.ReadWrite.All
  4. Create a Client Secret.
  5. Get:
    • PLANNER_PLAN_ID
    • PLANNER_BUCKET_ID via Graph Explorer.

Power Automate Flow

  1. Create a flow with When an HTTP request is received.
  2. Save β†’ copy the generated endpoint URL.

▢️ Running the Application

Option A β€” Docker Compose (recommended)

# Build and start both services
docker compose up --build

This starts the web app on http://localhost:8000 and the worker listening on the Service Bus queue. Both read from your .env file.

To build images individually:

docker build --target web    -t helpdesk-web    .
docker build --target worker -t helpdesk-worker .

Option B β€” Two Terminals (local dev)

Terminal 1 β€” FastAPI Web Server

uvicorn app.main:app --reload

Terminal 2 β€” Worker

python -m app.worker

☁️ Deploy to Azure Container Apps

The architecture maps naturally to Azure Container Apps β€” the web app and worker run as two separate container apps in a shared environment.

# Variables
RG=rg-helpdesk
LOCATION=westeurope
ENV_NAME=helpdesk-env
ACR_NAME=youracrname

# Create resource group & Container Registry
az group create -n $RG -l $LOCATION
az acr create -n $ACR_NAME -g $RG --sku Basic --admin-enabled true
az acr login -n $ACR_NAME

# Build & push both images
docker build --target web    -t $ACR_NAME.azurecr.io/helpdesk-web:latest    .
docker build --target worker -t $ACR_NAME.azurecr.io/helpdesk-worker:latest .
docker push $ACR_NAME.azurecr.io/helpdesk-web:latest
docker push $ACR_NAME.azurecr.io/helpdesk-worker:latest

# Create Container Apps environment
az containerapp env create -n $ENV_NAME -g $RG -l $LOCATION

# Deploy web app (with external ingress)
az containerapp create \
  -n helpdesk-web -g $RG \
  --environment $ENV_NAME \
  --image $ACR_NAME.azurecr.io/helpdesk-web:latest \
  --registry-server $ACR_NAME.azurecr.io \
  --target-port 8000 \
  --ingress external \
  --min-replicas 1 --max-replicas 3 \
  --env-vars-file .env

# Deploy worker (no ingress)
az containerapp create \
  -n helpdesk-worker -g $RG \
  --environment $ENV_NAME \
  --image $ACR_NAME.azurecr.io/helpdesk-worker:latest \
  --registry-server $ACR_NAME.azurecr.io \
  --min-replicas 1 --max-replicas 5 \
  --env-vars-file .env

Tip: For production, use Container Apps secrets or Azure Key Vault references instead of --env-vars-file.


πŸ“š References

Releases

Packages

Used by

Contributors

Languages