Triggering / Monitoring options?

I have a new situation for the trigger of our bot and I was wondering if you had any ideas or words of wisdom for me.

So, our trigger for starting this bot (process wise) will be when the customer drops a file into a folder for the bot. We want the bot to begin processing this file immediately.

Our best idea so far is to have the first thing for the bot does is check the file to see if there is anything in the folder, and if there’s nothing (or no relevant file) it stops. We would schedule this bot to run every minute, and possibly for 24 hours a day.

This idea seems kind of wasteful though and takes out an entire machine and unattended license in order to run one bot…

I was also thinking about a polling schedule or another idea could be to have the user upload the file to a website, where it could then send an http post to the Orchestrator API to kick off the job and supply the file location as a parameter. I am just very new and not sure how to achieve this?

Any advice is much appreciated thanks!

1 Like

You were good actually
This looks simple and easy compared to API
And I would suggest to always make the process with simple set of activities unless we need to incorporate the complex one

But instead of running for every minute run extend the schedule time ago a bit more so that the machine and memory won’t be taken a lot

Cheers @ChrystineHausman

2 Likes

I wonder if there is a way to have a small console app check for new files in that directory, and when one is found- use the Orchestrator API to start the job. This way you don’t have to build and manage a new site and you would have the added benefit of optimal license usage.

Monitor Folder (Powershell)

Trigger API Call
we could use this over here too, I’ll whip something up soon :slight_smile:

2 Likes

Hi @ChrystineHausman,

Have you tried the “File Change Trigger” Activity?

This activity monitors changes on a specified file or folder. Can only be used inside a Monitor Events activity.

https://docs.uipath.com/activities/docs/file-change-trigger

1 Like

Wouldn’t this option take up both a machine and a bot license?

@ChrystineHausman,

It will always be running and as soon as the user inputs something in the folder it will trigger what you want to trigger. It monitors just like the activity says, since we want to know in real time changes.
So the answer to your questions it’s yes basically.

1 Like

Thank you!

1 Like

Thanks so much!

1 Like

@ChrystineHausman If it needs to happen immediately and this is your only ‘Monitoring’ process, then you are right, it isn’t worth consuming an entire license. If you have many processes that require monitoring events, then it makes sense to have a ‘Monitor bot’ that monitors for all of these things and starts the appropriate process.

Since you only have one i think it’s best to make a small daemon process outside of uipath that is monitoring for file and/or directory changes, and utilize the API to start the process

2 Likes

Thank you Dave! Would maybe a powershell script work? I was hoping maybe something like this and then I can use Windows Task Scheduler to kick it off if needed? eg below:

### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
    $watcher = New-Object System.IO.FileSystemWatcher
    $watcher.Path = "D:\source"
    $watcher.Filter = "*.*"
    $watcher.IncludeSubdirectories = $true
    $watcher.EnableRaisingEvents = $true  

### DEFINE ACTIONS AFTER AN EVENT IS DETECTED
    $action = { $path = $Event.SourceEventArgs.FullPath
                $changeType = $Event.SourceEventArgs.ChangeType
                $logline = "$(Get-Date), $changeType, $path"
                Add-content "D:\log.txt" -value $logline
              }    
### DECIDE WHICH EVENTS SHOULD BE WATCHED 
    Register-ObjectEvent $watcher "Created" -Action $action
    Register-ObjectEvent $watcher "Changed" -Action $action
    Register-ObjectEvent $watcher "Deleted" -Action $action
    Register-ObjectEvent $watcher "Renamed" -Action $action
    while ($true) {sleep 5}

I wouldnt use task scheduler, you want it to run continuously right? Instead I would save it as a windows service that runs in the background all the time (or if not possible, just put it on local machine’s startup folder).

1 Like

@Dave Thanks so much, you’re my hero! Happy Halloween!!

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