-
-
Save KyMidd/ad02312a72dea7ccf64429db15f8be43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def respond_to_teams(bot_bearer_token, event_body, message): | |
| # Build auth headers | |
| headers = { | |
| "Authorization": f"Bearer {bot_bearer_token}", | |
| "Content-Type": "application/json", | |
| } | |
| # Create message payload | |
| payload = { | |
| "type": "message", | |
| "text": message, | |
| } | |
| # Find the service URL and conversation ID from the event body | |
| service_url = event_body["serviceUrl"] | |
| conversation_id = event_body["conversation"]["id"] | |
| # Send the message to Teams | |
| response = requests.post( | |
| f"{service_url}/v3/conversations/{conversation_id}/activities", | |
| headers=headers, | |
| json=payload | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment