UIPath and Slack

I am using UIPath to paste a message into a Slack channel. It is working fine most of the time.
I use OpenBrowser to open Slack to the correct channel.
Then use Send Hotkey to paste in the message.

The problem is that if I have the Slack App open as well the text will be pasted into that window in whatever channel happens to be selected - even though the focus must be on the browser window I had just opened.
It seems that the Slack app uses the default browser for the window it opens - so effectively I have two browser windows open with Slack in each.

Anyone know how I can ensure that UIPath uses the browser window I just opened?

1 Like

hey Nigle Barret,

under Open browser activity you can select browser type
image

regards
Aditya

Thanks Adiya, that is certainly a workaround that I can use.

But if anyone has another solution I would be interested - ie one that does not require setting up another browser.

I have discovered that I can kill the Slack process before opening Slack in a browser. Now there is no risk of posting in the wrong channel.

Happy Automation!! :wink:

Hi @NigelBarrett,

I am trying to automate sending message through Slack application. But unfortunately, UiPath is unable to identify elements to select/click/Type. On selecting elements using UiPath Explorer, it shows error message “Cannot find the UI Object for the selector you have provided!”. Please let me know if you have faced any kind of issue in Slack Desktop application.

Regards,
Arun

Hi Arun

Yes, I had similar problems.

In the end I did the following:

  • Use UIPath to

    • Close the Slack app

    • Open a browser at the correct channel

    • Paste in the message

    • Open the Slack app

As far as I can tell Slack uses your default browser to create the Slack app window. This will have the same name as one of the current open browser windows.

Even if the focus is on the browser window I found it would jump to the Slack app window and paste into whatever channel happened to open.

I never succeeded in overcoming the message you ask about but all I wanted to do was paste the message into the correct channel which I managed with the points above.

Nigel

Ok Got it.

Thank you :slight_smile:``

It would be better option to send slack message using incoming webhooks, instead of relying on Ui.

1 Like

People!! Use invoke powershell and this code

"param(
[parameter(Position=0,Mandatory=$false)][string]$MessageBot
)

$payload = @{
‘channel’ = ‘#ChanellName
‘text’ = 'Robot: '+ $MessageBot
}

Invoke-WebRequest -Body (ConvertTo-Json -Compress -InputObject $payload)
-Method Post `
-Uri ‘Customize your workspace | Slack’ | Out-Null"

MessageBot is string that contains your message inside UiPath
Check IsScript
TypeOfArgument to be String
In Parameters add Arguments you want to pass to PS and send message directly to slack

Thanks - just tried this and it says missing parameters.
What does you last line mean? What parameters do I need to add?

So Paramaters

image

And then add your arguments that you want to pass

And here is link for Slack webhook

Thanks again Rodomir. I have the app integrated to the correct channel. Now I am getting an error saying there is something wrong with the uri parameter. What should I be pasting in there? I tried the webhook and the token.

Ok so, step-by-step

Connecting UiPath with Slack channel

There is a way to connect UiPath robot with Slack channel. With this feature we can send messages to Slack and have live preview of logs.
To do that please follow these steps:

  1. Go to Sending messages using Incoming Webhooks | Slack and Enable incoming webhooks
  2. Create your Slack App
    image

Give a name to your App and select your workspace, after that click on Create App

  1. After that you will get Basic information about your app where you need to enable Incoming WebHook
    image

Click on Incoming Webhooks

  1. Activate Incoming Webhooks

image

  1. Click on Add New Webhook to Workspace, and assign Webhook to your channel

image
image

And click on Install

  1. Copy your Webhook URL

image

  1. Test it first with PowerShell, open PowerShell and paste this code in

param(
[parameter(Position=0,Mandatory=$false)][string]$MessageBot
)

$payload = @{
‘channel’ = ‘#channel_name
‘text’ = 'Robot: '+ $MessageBot
}

Invoke-WebRequest -Body (ConvertTo-Json -Compress -InputObject $payload)
-Method Post `
-Uri ‘Customize your workspace | Slack’ | Out-Null


  • Replace Uri URL with Webhook URL
  • Replace #Channel_Name with your channel name
  • ‘text’ = ‘PUT YOUR ROBOT TEXT HERE’ + $MessageBot ($MessageBot is argument that will come from UiPath)

And hit in PowerShell and test your connection, if everything works proceed to step 8.

  1. Open UiPath
  • Add Argument MessageBot
  • Add Assign activity to workflow
  • Add activity Invoke PowerShell command
  • Paste code from PowerShell that you tested to Invoke powershell (use quotations)
  • In Properties check ISCODE

image

  1. Now MessageBot is your argument that will go from UiPath to Slack. That is it.
3 Likes

uri is URL of youe webhook

Thank you Radomir, you are a star.
Unfortunately I did not get it to work even after a few hours of trying following your directions to the letter. Perhaps there is some other block on our set up.

Just FYI: I got as far as pasting the code into Powerscript - it seemed to accept the code but nothing appeared in the Slack channel.

Did you properly copied webhook? And for the same webhook you must have that channel name?

This is working for me, also in powershell you should be able to send it, maybe its on Slack side…

Or a Workspace in Slack… can you check are you in that workspace?

Hello Nigel,
Here you can see 2 movies where I work with Slack:

Thanks,
Cristian Negulescu

1 Like

Hi,
can u plz guide me how paste the message into a slack?
My task is to read a message from one channel and want to paste it in another channel.
Kindly help me on the same

Hello,

You have Slack activities. Now reading messages from slack can be tricky, but posting is quite easy.

If you dont find your way around Slack activities,let me know and Ill help.

Cheers,
Radomir