Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 23, 2025 01:08
Show Gist options
  • Select an option

  • Save KyMidd/ad02312a72dea7ccf64429db15f8be43 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/ad02312a72dea7ccf64429db15f8be43 to your computer and use it in GitHub Desktop.
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