Forum Discussion

fabin10's avatar
fabin10
Brass Contributor
Jul 20, 2021

How to get user email by ID on Message extension created using Microsoft Bot Framework?

Hi,

 

I am using Microsoft Bot Framework to create a message extension. I would like to get the user email of customers who enter the search query in the command box. I am able to get the user email id in the normal search, ie in the bottom search and chatbox. But the same method is not working when I search the content using the command box by entering @appname . The following method is used to get the user email id in a normal search

 

 

export default class MessageExtension extends TeamsActivityHandler {
async handleTeamsMessagingExtensionQuery(context, query) {
   
    let searchQuery = query.parameters && query.parameters[0].name === 'query'
        ? query.parameters[0].value
        : '';

 
    console.log("searchQuery="+searchQuery);   
    console.log("query="+JSON.stringify(query));      

    const member = await this.getTeamMember(context);
        console.log("email="+member);}}

async getSingleMember(context) {
  try {
      const member = await TeamsInfo.getMember(
          context,
          context.activity.from.id
      );
      var email = member.email;
      const message = MessageFactory.text(`You are: ${member.email}`);
      return email
  } catch (e) {
      if (e.code === 'MemberNotFoundInConversation') {
          return context.sendActivity(MessageFactory.text('Member not found.'));
      } else {
          throw e;
      }
  }}

 

 

Does anyone know how we can get it?

Screenshot of the command box search area

 

 

 

  • Hi, We are able to repro this issue. We are currently looking into it and will get back to you.
    • fabin10's avatar
      fabin10
      Brass Contributor

      Prithvi-MSFTThanks for the update. The issue is only when we call the extension from the topbar command box like @appname:<search text> and in other situations we are able to get the user details using the folowing code

       

      const member = await TeamsInfo.getMember(
                context,
                context.activity.from.id
            );

       

       Is the above method will not work if we do the search from command box?

       

Resources