Skip to content

omar3anan/Microsoft-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft-Teams-Integration.

Microsoft Integration using Microsoft Graph API

This repository contains sample code and instructions on how to integrate with Microsoft Graph API to interact with chat messages and channels in Microsoft Teams.

Getting Started

These instructions will help you set up and use the integration to retrieve and post messages using Microsoft Graph API.

Prerequisites

  • Microsoft Azure Account
  • Microsoft Teams Account
  • Python 3.x
  • requests library (Install using pip install requests)

Authentication

  1. Go to the Azure Portal.
  2. Create a new App Registration.
  3. Note down the Application (client) ID and create a new client secret.
  4. Grant necessary permissions (e.g., Chat.Read, ChatMessage.ReadWrite.All) to your app registration.
  5. Get your tenant ID from the Azure portal.

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/microsoft-graph-chat-integration.git
cd microsoft-graph-chat-integration
    
  1. Create a virtual environment (optional but recommended):
python3 -m venv venv
source venv/bin/activate  
    
  1. Install required packages:
pip install -r requirements.txt
    
  1. Rename config.sample.json to config.json and fill in your app registration details:
{
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "tenant_id": "YOUR_TENANT_ID"
}
    

Usage

  1. Run the script to retrieve chat messages:
python get_chat_messages.py --chat_id "CHAT_ID"
    
  1. Run the script to post a message to a chat:
python post_chat_message.py --chat_id "CHAT_ID" --message "Hello from Microsoft Graph API!"
    
  1. Run the script to post a message to a channel:
python post_channel_message.py --channel_id "CHANNEL_ID" --message "Hello from Microsoft Graph API!"
    

Contributing

Feel free to contribute to this project by creating issues or pull requests. Your feedback and contributions are welcome!

License

This project is licensed under the MIT License - see the LICENSE file for details.