# Teams Webhook
A simple Python package to send messages to Microsoft Teams using webhooks.
## Features
- Easy-to-use interface for sending Teams messages
- Support for rich message cards with titles, subtitles, and images
- Customizable theme colors
- Error handling and response validation
- Both class-based and function-based APIs
## Installation
```bash
pip install teams-webhook
```
## Quick Start
### Using the Class
```python
from teams_webhook import TeamsWebhook
# Initialize with your webhook URL
webhook = TeamsWebhook("https://your-company.webhook.office.com/webhookb2/your-webhook-url")
# Send a message
result = webhook.send_message(
message_title="🚨 Alert",
activity_title="System Monitor",
activity_subtitle="Health Check",
text_message="This is a test message!"
)
print(f"Success: {result['success']}")
```
### Using the Function
```python
from teams_webhook import send_teams_message
# Send a message directly
result = send_teams_message(
webhook_url="https://your-company.webhook.office.com/webhookb2/your-webhook-url",
message_title="📊 Status Update",
activity_title="Automation Bot",
activity_subtitle="QA Automation",
text_message="**Status:** All systems operational"
)
```
## Parameters
### Required Parameters
- `webhook_url` (str): Your Microsoft Teams webhook URL
- `message_title` (str): The main title of the message
- `activity_title` (str): The activity title in the message card
- `activity_subtitle` (str): The activity subtitle in the message card
- `text_message` (str): The main text content of the message
### Optional Parameters
- `theme_color` (str): The theme color of the message card (default: "0076D7" - blue)
- `activity_image` (str): URL of the activity image
## Examples
### Error Alert
```python
from teams_webhook import TeamsWebhook
webhook = TeamsWebhook("your-webhook-url")
result = webhook.send_message(
message_title="🚨 Critical Error",
activity_title="Error Monitor",
activity_subtitle="Service Alert",
text_message="**Error Level:** CRITICAL<br>**Service:** webapp-service<br>**Error:** Database connection failed",
theme_color="FF0000", # Red for error
activity_image="https://example.com/error-icon.png"
)
```
### Status Update
```python
from teams_webhook import send_teams_message
result = send_teams_message(
webhook_url="your-webhook-url",
message_title="📊 Status Update",
activity_title="System Monitor",
activity_subtitle="Health Check",
text_message="**Status:** All systems operational<br>**Uptime:** 99.9%",
theme_color="00FF00" # Green for success
)
```
## Response Format
The package returns a dictionary with the following structure:
```python
{
"success": True, # Boolean indicating if the request was successful
"status_code": 200, # HTTP status code
"message": "Message sent successfully to Microsoft Teams!",
"response": "..." # Raw response from Teams
}
```
## Error Handling
The package handles various error scenarios:
- Network connectivity issues
- Invalid webhook URLs
- Teams service unavailability
- Malformed message payloads
All errors are caught and returned in the response dictionary with appropriate error messages.
## Getting a Teams Webhook URL
1. Go to your Microsoft Teams channel
2. Click on the three dots (...) next to the channel name
3. Select "Connectors"
4. Find "Incoming Webhook" and click "Configure"
5. Fill in the details and click "Create"
6. Copy the webhook URL
## Requirements
- Python 3.7+
- requests library
## License
MIT License
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Changelog
### 1.0.0
- Initial release
- Basic webhook functionality
- Class and function-based APIs
- Error handling and response validation
Raw data
{
"_id": null,
"home_page": "https://github.com/pandiyarajk/teams-webhook",
"name": "teams-webhook",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "microsoft, teams, webhook, notification, messaging",
"author": "Pandiyaraj Karuppasamy",
"author_email": "Pandiyaraj Karuppasamy <pandiyarajk@live.com>",
"download_url": "https://files.pythonhosted.org/packages/bf/7b/7a55d5250413b42578975d56446b1aeecb58660c15613b798eaf2786bc28/teams_webhook-1.0.0.tar.gz",
"platform": null,
"description": "# Teams Webhook\r\n\r\nA simple Python package to send messages to Microsoft Teams using webhooks.\r\n\r\n## Features\r\n\r\n- Easy-to-use interface for sending Teams messages\r\n- Support for rich message cards with titles, subtitles, and images\r\n- Customizable theme colors\r\n- Error handling and response validation\r\n- Both class-based and function-based APIs\r\n\r\n## Installation\r\n\r\n```bash\r\npip install teams-webhook\r\n```\r\n\r\n## Quick Start\r\n\r\n### Using the Class\r\n\r\n```python\r\nfrom teams_webhook import TeamsWebhook\r\n\r\n# Initialize with your webhook URL\r\nwebhook = TeamsWebhook(\"https://your-company.webhook.office.com/webhookb2/your-webhook-url\")\r\n\r\n# Send a message\r\nresult = webhook.send_message(\r\n message_title=\"\ud83d\udea8 Alert\",\r\n activity_title=\"System Monitor\",\r\n activity_subtitle=\"Health Check\",\r\n text_message=\"This is a test message!\"\r\n)\r\n\r\nprint(f\"Success: {result['success']}\")\r\n```\r\n\r\n### Using the Function\r\n\r\n```python\r\nfrom teams_webhook import send_teams_message\r\n\r\n# Send a message directly\r\nresult = send_teams_message(\r\n webhook_url=\"https://your-company.webhook.office.com/webhookb2/your-webhook-url\",\r\n message_title=\"\ud83d\udcca Status Update\",\r\n activity_title=\"Automation Bot\",\r\n activity_subtitle=\"QA Automation\",\r\n text_message=\"**Status:** All systems operational\"\r\n)\r\n```\r\n\r\n## Parameters\r\n\r\n### Required Parameters\r\n\r\n- `webhook_url` (str): Your Microsoft Teams webhook URL\r\n- `message_title` (str): The main title of the message\r\n- `activity_title` (str): The activity title in the message card\r\n- `activity_subtitle` (str): The activity subtitle in the message card\r\n- `text_message` (str): The main text content of the message\r\n\r\n### Optional Parameters\r\n\r\n- `theme_color` (str): The theme color of the message card (default: \"0076D7\" - blue)\r\n- `activity_image` (str): URL of the activity image\r\n\r\n## Examples\r\n\r\n### Error Alert\r\n\r\n```python\r\nfrom teams_webhook import TeamsWebhook\r\n\r\nwebhook = TeamsWebhook(\"your-webhook-url\")\r\n\r\nresult = webhook.send_message(\r\n message_title=\"\ud83d\udea8 Critical Error\",\r\n activity_title=\"Error Monitor\",\r\n activity_subtitle=\"Service Alert\",\r\n text_message=\"**Error Level:** CRITICAL<br>**Service:** webapp-service<br>**Error:** Database connection failed\",\r\n theme_color=\"FF0000\", # Red for error\r\n activity_image=\"https://example.com/error-icon.png\"\r\n)\r\n```\r\n\r\n### Status Update\r\n\r\n```python\r\nfrom teams_webhook import send_teams_message\r\n\r\nresult = send_teams_message(\r\n webhook_url=\"your-webhook-url\",\r\n message_title=\"\ud83d\udcca Status Update\",\r\n activity_title=\"System Monitor\",\r\n activity_subtitle=\"Health Check\",\r\n text_message=\"**Status:** All systems operational<br>**Uptime:** 99.9%\",\r\n theme_color=\"00FF00\" # Green for success\r\n)\r\n```\r\n\r\n## Response Format\r\n\r\nThe package returns a dictionary with the following structure:\r\n\r\n```python\r\n{\r\n \"success\": True, # Boolean indicating if the request was successful\r\n \"status_code\": 200, # HTTP status code\r\n \"message\": \"Message sent successfully to Microsoft Teams!\",\r\n \"response\": \"...\" # Raw response from Teams\r\n}\r\n```\r\n\r\n## Error Handling\r\n\r\nThe package handles various error scenarios:\r\n\r\n- Network connectivity issues\r\n- Invalid webhook URLs\r\n- Teams service unavailability\r\n- Malformed message payloads\r\n\r\nAll errors are caught and returned in the response dictionary with appropriate error messages.\r\n\r\n## Getting a Teams Webhook URL\r\n\r\n1. Go to your Microsoft Teams channel\r\n2. Click on the three dots (...) next to the channel name\r\n3. Select \"Connectors\"\r\n4. Find \"Incoming Webhook\" and click \"Configure\"\r\n5. Fill in the details and click \"Create\"\r\n6. Copy the webhook URL\r\n\r\n## Requirements\r\n\r\n- Python 3.7+\r\n- requests library\r\n\r\n## License\r\n\r\nMIT License\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## Changelog\r\n\r\n### 1.0.0\r\n- Initial release\r\n- Basic webhook functionality\r\n- Class and function-based APIs\r\n- Error handling and response validation\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A simple Python package to send messages to Microsoft Teams using webhooks",
"version": "1.0.0",
"project_urls": {
"Bug Reports": "https://github.com/pandiyarajk/teams-webhook/issues",
"Documentation": "https://github.com/pandiyarajk/teams-webhook#readme",
"Homepage": "https://github.com/pandiyarajk/teams-webhook",
"Repository": "https://github.com/pandiyarajk/teams-webhook"
},
"split_keywords": [
"microsoft",
" teams",
" webhook",
" notification",
" messaging"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ed8a73a086647cb412ce9b817d5c58b44d46ed556b8631222c233801c6be3dd1",
"md5": "307d44f77b39a52bb3536126cc333394",
"sha256": "3d7d58566c77b6f3a8684b10d424249e0e5cd3e5749b57c4f859492eb7b5de57"
},
"downloads": -1,
"filename": "teams_webhook-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "307d44f77b39a52bb3536126cc333394",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7684,
"upload_time": "2025-09-15T17:39:14",
"upload_time_iso_8601": "2025-09-15T17:39:14.048359Z",
"url": "https://files.pythonhosted.org/packages/ed/8a/73a086647cb412ce9b817d5c58b44d46ed556b8631222c233801c6be3dd1/teams_webhook-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bf7b7a55d5250413b42578975d56446b1aeecb58660c15613b798eaf2786bc28",
"md5": "91b0aaf88d17822d6dc18368499e2d2c",
"sha256": "b9bf86cf49677ebc8546bbf8cccd7acf49db5682943de64a8587c2a836cabda4"
},
"downloads": -1,
"filename": "teams_webhook-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "91b0aaf88d17822d6dc18368499e2d2c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8829,
"upload_time": "2025-09-15T17:39:15",
"upload_time_iso_8601": "2025-09-15T17:39:15.628320Z",
"url": "https://files.pythonhosted.org/packages/bf/7b/7a55d5250413b42578975d56446b1aeecb58660c15613b798eaf2786bc28/teams_webhook-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-15 17:39:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pandiyarajk",
"github_project": "teams-webhook",
"github_not_found": true,
"lcname": "teams-webhook"
}