Microsoft Teams
A Microsoft customizable chat-based workspace.
9,980 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am developing a chatbot using Microsoft Teams Bot Builder SDK, I managed to get my user profile details however, it comes together with the Bot's which is not required.
The ouput:
"Welcome Syafie!"
"Welcome! We couldn't retrieve your detailed information."
The code:
async def on_members_added_activity(
self, members_added: List[ChannelAccount], turn_context: TurnContext
):
for member in members_added:
# Attempt to get the Teams member information
teams_member = await self.get_member(turn_context, member.id)
if teams_member:
self.full_name = f"{teams_member.given_name} {teams_member.surname}"
self.name = teams_member.given_name
self.email = teams_member.email
self.organization = self.email.split("@")[1].split(".")[0]
self.selected_option = self.organization
await turn_context.send_activity(greeting(self.name))
else:
self.selected_option = None
await turn_context.send_activity("Welcome! We couldn't retrieve your detailed information.")
async def get_member(self, turn_context: TurnContext, member_id: str) -> TeamsChannelAccount:
try:
if turn_context.activity.channel_data:
member = await TeamsInfo.get_member(turn_context, member_id)
return TeamsChannelAccount().deserialize(member.serialize())
else:
raise ValueError("No channel_data available in TurnContext activity.")
except Exception as e:
print(f"Error retrieving member: {e}")
return None