finos / spring-bot

Spring Boot + Java Integration for Symphony/Teams Chat Platform Bots and Apps
https://springbot.finos.org
Apache License 2.0
60 stars 35 forks source link

Unable to get user from mention on MS teams #317

Closed nmwael closed 2 years ago

nmwael commented 2 years ago

I have this method but no matter what I do I cannot get the user mentioned (userA) in the chat to the bot:


    @ChatRequest(value = "echoUser {userA}",  description = "writeback user details")
    public MessageResponse echoUser(Addressable a, @ChatVariable("userA")  Optional<TeamsUser> userA) {
        if(userA.isPresent() && userA.isPresent()) {
            return new MessageResponse(a, "user  A<" + userA.get().getKey() + userA.get().getName() + ">");
        }else
        {
            return new MessageResponse(a, "user not found" );

        }
    }

Im very unsure if its just some kind of permission I need to give to my bot or application registration.. I can get the Addressable

nmwael commented 2 years ago

im double checking, something.. This might be related to the fact that Im running on mixed environments.. Trial for teams and msdn for azure..

nmwael commented 2 years ago

Ok remade this on a clean system, and still no luck.

robmoffat commented 2 years ago

HI @nmwael, sorry - for some reason I missed this notification. Let me take a look today and get back to you

robmoffat commented 2 years ago

Right, so I checked out the latest code for demo-bot from spring-bot-develop branch and added your controller code above. It mainly works for me:

Screenshot 2022-05-12 at 12 47 34

A couple of things:

 @ChatRequest(value = "echoUser {userA}",  description = "writeback user details")
    public MessageResponse echoUser(Addressable a, @ChatVariable("userA")  Optional<TeamsUser> userA) {
        if(userA.isPresent() && userA.isPresent()) {
            return new MessageResponse(a, Message.of(Word.of("User "), userA.get()));
        }else
        {
            return new MessageResponse(a, "user not found" );

        }
    }

And that will produce this output:

Screenshot 2022-05-12 at 12 50 49
robmoffat commented 2 years ago

.. just checking something else - you did all the ngrok stuff and you can see the bot being called on your Java console, right?

nmwael commented 2 years ago

Yup

On Thu, May 12, 2022, 13:53 Rob Moffat @.***> wrote:

.. just checking something else - you did all the ngrok stuff and you can see the bot being called on your Java console, right?

— Reply to this email directly, view it on GitHub https://github.com/finos/spring-bot/issues/317#issuecomment-1124898504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF3P5YHIUNW4NWULP6ZXXLVJTWNHANCNFSM5T6AFF7Q . You are receiving this because you were mentioned.Message ID: @.***>

robmoffat commented 2 years ago

isn't that the other issue you raised? I think it's better if we treat them separately.

Let me see if I can help you debug this. If you type echoUser @somepersoninthechat:

  1. Does the echoUser method get called?
  2. If so, what is the value of userA?

Let's start with that.

nmwael commented 2 years ago

Okay, yes the methods is called and I think you have addressed my problem.. I was @ someone who was not in the chat.. Is it not possible at all? Our chat bot is a system management bot, which configures stuff on users voice settings on teams. AFAIK the ms /who bot can check users not in chat, but is that because its not a 1-1 chat?

robmoffat commented 2 years ago

I think this is just a MS Teams thing - you can only mention people in the chat/channel. It's a pretty annoying restriction. Also, you can't mention yourself!! See: