Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 24, 2025 15:43
Show Gist options
  • Select an option

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

Select an option

Save KyMidd/33998915666af6910b9690094aff5436 to your computer and use it in GitHub Desktop.
def get_teams_conversation_history(user_graph_auth_token, event_body):
#...
if conversation_type == "channel":
#...
# Fetch all responses in the Post/thread
url = f"https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/messages/{parent_message_id}/replies"
# Get previous messages
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise Exception(f"Graph API error {response.status_code}: {response.text}")
data = response.json()
messages = data.get("value", [])
# Sort so we get the oldest first
messages = list(reversed(messages))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment