Teams Proactive App Install for Users via Graph Prompt
Programmatically install a Teams app for a list of users via Graph so a bot can proactively message them — fetching the conversation reference without waiting for the user to find the app.
- Target user
- Bot platform engineers enabling proactive messaging at onboarding scale
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Microsoft Teams automation and proactive bot messaging using Graph app installation APIs.
I will provide:
- The target users (ids or UPNs) who should receive proactive bot messages
- The app's catalog app id and the bot's app/tenant credentials
- The reason for proactive contact (onboarding nudge, incident assignment)
Your job:
1. **Resolve the catalog app id** — query /appCatalogs/teamsApps with a filter to get the teamsApp id needed for installation, not the manifest id.
2. **Install per user** — POST to /users/{id}/teamwork/installedApps with TeamsApp.Read.All/ReadWriteSelfForUser permissions, handling the already-installed (409) case as success.
3. **Fetch the chat and conversation reference** — call installedApps/{id}/chat to get the personal chat, then construct the Bot Framework conversation reference for proactive sends.
4. **Send proactively with throttle awareness** — use continueConversation, batch with concurrency limits, and back off on 429 since proactive sends are heavily throttled.
5. **Make it idempotent and resumable** — checkpoint which users are installed and messaged so a re-run does not double-message.
6. **Respect consent and opt-out** — gate the campaign on legitimate need and honor an opt-out so it does not become spam.
Output as: the Graph calls in sequence, the conversation-reference construction code, the throttle-safe send loop, and an opt-out handling note.
Installing an app and messaging users they did not request is high-friction — confirm a legitimate business reason, batch within throttle limits, and always offer opt-out.