Forum Discussion
App Validation Issue - Bot must send a proactive welcome message in personal scope
Thanks Nivedipa-MSFT , Based on your recommendation, I have implemented the following changes to address the issues. These modifications appear to have resolved the problems.
Graph API queries may generate unexpected conversationUpdate events:
I've implemented deduplication logic in on_members_added_activity. Started saving conversation ID in a conversation reference db table after triggering welcome messages. Logic checks whether a conversation ID exists in our conversation reference table before triggering welcome messages.
Reading Chat History :
Used user id and bot id from context to construct chat id
conversation_reference = turn_context.activity.get_conversation_reference()
user_id = conversation_reference.user.aad_object_id
bot_id = conversation_reference.bot.id
# Strip the "28:" prefix from bot_id
if bot_id and bot_id.startswith("28:"):
bot_id = bot_id[3:]
chat_id = (f"19:{user_id}_{bot_id}@unq.gbl.spaces")
messages_url = (
f"{graph_url}/me/chats/{chat_id}/messages?"
"$top=10&$orderby=createdDateTime desc"
)
messages_response = requests.get(messages_url, headers=headers)
App Validation – Proper Procedure:
For one-on-one chats, used on_members_added_activity to detect when the bot joins and trigger the welcome flow.
For other scenarios (like team channels or group chats), use on_installation_update to handle the bot's installation event.