I am using the TeamsInfo library to get the user’s profile info through on_members_added. I succeeded to the my user’s profile info however, my chatbot also returns the bot’s detail which is undesired. I need your help to return only my info instead of both with the bot.
the ouput:
"Hi Adam!" --my info
"Welcome! We couldn't retrieve your detailed information." -- the bot's
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
I need your help to return only my info instead of both with the bot.