Microsoft Teams Chatbot Idea: Get last message in a chat conversation (selector issue)

Hello everyone, I am currently evaluating the possibility of developing a small chatbot in Microsoft Teams. Please note that I am well aware of that there is a Microsoft Teams Connector for UiPath but I am currently not able to setup this connector for the company. That is why I am thinking about a small workaround.

The idea is quite simple.

I want to get the last (or latest) message in a chat conversation and use ‘Get Text’ or ‘Get Full Text’ to extract the message. Then I want to create a selection of actions that will be triggered through the chat message (depending on the content).

I could manage the “response” part but I am struggling with getting the text message (I am not able to get a stable selector). I only want to get the last received message in a chat. I could yet only manage to manually set the selector of the last chat message to make it work but this will not work as a solution.

I also tried a workaround by using “Anchor Base Activity” but it always gives me an empty string as output.

Does anyone have an idea to solve my issue?

Thanks in advance.

Hey @SenorChang

Will be helpful if you post the selector of the element

Thanks

Hi @Nithinkrishna,

Here is the selector:

<wndapp=‘teams.exe’ cls=‘Chrome_WidgetWin_1’ title=‘* | Microsoft Teams’ />



What I found out is that the value indicates the message element which is required.

Edit: Somehow, the selector is not fully shown in the message. I attached a screenshot of the selector.
screenshot selector

Can you share the uiexplorer screenshot by validating this selector please…

Thanks

Here is the screenshot (unfortunately the Ui Explorer language is in German unlike the language in Studio which is English. But I have put the translation in the above image. I cannot see a unique identifier for a message in Microsoft Teams.

1 Like

Thats okay @SenorChang.

Now I got some view on what you want.

(Logic)So what can I suggest is like - Scrape the entire chatbox in the selector & traverse to last message.

One method is like, You may use find children activity as well and then retrieve the last children.

You may use any method, but the ultimate logic is same as mentioned.

If you still want help like a sample code I will just signup teams and let me know your username so that I can ping you and achieve the result.

Thanks, Feel free to post your thoughts.

Hey @Nithinkrishna,

Thank you for the suggestion. I experienced that the ‘Find Children’ activity is not useful for my issue because it reads all messages in the whole conversation (i am not sure how many messages will be collected over some time…must be thousands). This would also be a very slow option. Anyways I found an other quite creative way to achieve the goal using hotkey for navigation. Works reliably for now. Thanks again for your input. Appreciate!

BR

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.