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?
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
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
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.
@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
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).