How can I create a Slack command with a file attachment - slack

I would like to create a Slack command /command do-something-with-that-file with at the same time, the user uploading the file.
So far, my command is received but there is no files in the payload.
Is this possible?
I have also added files:read in the scope but no luck so far.

A Slack command can only accept text as input. If you upload a file at the same time, it wouldn't be a part of the payload and will be ignored (although uploaded, and accessible through file browser).
Some alternatives you could try though:
Use files.list method - Look for files uploaded within a few seconds of the moment when you receive the command. The method accepts ts_from and ts_to parameters for this purpose.
Use file_shared event - Subscribe to this event in your app configuration. This event fires every time a file is uploaded in a channel visible to your bot. You could ask the app user to use a certain format to provide with a file upload, and look for a pattern in the event submission.
Use message shortcut - Once a user uploads a file, you can ask them to use the context menu to fire a message shortcut associated with your app. This message shortcut contains a reference to the message ID, which can be used to fetch the uploaded file.

Related

Slack API slash command stripping out hyperlinks

I have created a slash command in Slack and am successfully receiving the relevant payload from that slash command. However, when the user creates a message that contains an embedded hyperlink, that link is being stripped out of the message and isn't included in the message payload.
For example:
This message contains a link
...gets converted to:
This message contains a link
Oddly, the link is successfully passed through as part of the payload if the user types a naked URL in their message, but it does not work if they create a link using the 'link' button in the Slack UI.
As per the docs, I have enabled the option "Escape channels, users, and links sent to your app" but this doesn't seem to fix the problem.
Can anyone help? How can ensure embedded hyperlinks aren't stripped out of the message payload?
Slack unfortunately haven't spent much time on slash commands since launch, and one of the things they don't support are links, as they were only added recently to the client's rich text editor.
Previously there was no way to create a link to a non-slack resource without pasting the full URL, so the slash command isn't sent it.
Your best option, if you are trying to do something with a link, would be to respond ephemerally to the user stating this and asking them to send the full URL via the slash command instead.

Running Excel Scripts on Outlook Attachments then sending processed files

TL;DR: I want to extract an Excel attachment from an Outlook message, automate an Excel script on the unprocessed reports, and then send the output in a new email message.
I have reports from Amazon that I have sent to a specific email on my Outlook folder each month.
I set up Power Automate to trigger whenever an email with an attachment is received in this folder.
I want to take the attachment in this Outlook email and run an Excel script that I build on Excel Desktop (not an Excel application macro) to format the data.
And then I want to send the output/result (scripted email attachment) as the body of an email out to clients.
I've gotten the first and last parts to run, but I can't get the script to process the file, that's the phase that always breaks that automation.
Things that I think might be causing the issue:
Do I need to extract the attachment from the email and save it as a file before I can run the Excel script on it?
Does the attachment need to be saved through Share Point to be later referenced by the Excel script?
Does the script need to be on the same or different cards as previous steps?
I've seen people run the Excel script through a Scope.
I've also looked at every available YouTube video to troubleshoot this: some go over certain steps in the process, but I'm having a hard time threading everything together.
Other Things I've Tried
I also tried to build a macro that does the same thing as my Excel desktop automation, and then wrote VBA code so each time a new sheet is opened the same macro is run, processing the data. But I couldn't get it to run on any new future sheet that I open, even when writing the VBA auto-open code in Module as well as This Worksheet.
I'm open to any method that will make this work.
Get email (V2) - Message ID
#{triggerOutputs()?['body/id']}
Apply to Each - Select an output from previous steps
#{outputs('Get_email_(V2)')?['body/attachments']}
Create File - File Name
#{items('Apply_to_each')?['name']}
Create File - File Content
#{items('Apply_to_each')?['contentBytes']}
Move or rename a file - File (make sure you add .xlsx for Destination File Path)
#outputs('Create_file')?['body/Id']
Run Script - File
#outputs('Move_or_rename_a_file')?['body/Id']
Get file content - File
#outputs('Move_or_rename_a_file')?['body/Id']
Send an email (V2) - Attachments Name-1
#outputs('Move_or_rename_a_file')?['body/DisplayName']
Send an email (V2) - Attachments Content - 1
#body('Get_file_content')?['body']

Cannot read Outlook Sent Items with Blue Prism Mapiex Get Mail function

I tested reading mail from Sent Items with BP Mapiex Get Mail, but it only works with Inbox (default folder in action). Folder name is correct (I took it as I see it in Outlook).
Error message: Failure in Get Mail function of Blue Prism Extended
MAPI Automation. Failed to open sub-folder 'Sent Items'.
Would anyone have any ideas, what can help it work with Sent Items?
Thanks!
This is because Get Mail was configured to look in the Inbox only (and sub folders within the inbox). You can add a rule in Outlook to move the sent items to a sub-folder (then you use the Get Mail action), or add a new page in your MAPIEx object. If you go with the latter, you can proceed like this:
Open the MAPIEx object and duplicate the page called 'Get Mail', rename the page and the code stage to something else, such as Get Sent Items, then publish it. I did it this way:
Open the code stage and edit this line (line 17) so that it looks like the following, from OpenInbox() to OpenSentItems():
Editing the highlighted items is optional but preferable as it makes it easier to debug should there be issues. For instance, you would change anything that says Inbox to Sent Items.
From there you can call the action from your process just like you would call Get Mail.

How to make a Finder Sync Extension change badges in response to outside events

I have a Finder Sync Extension that will display a badge on a file based on the state of a local database. It's straightforward enough to query this database in the requestBadgeIdentifierForURL function, but what if I want the badge to change for a Finder item that's already visible if the state of that database has changed (which can be via a notification through any variety of mechanisms). The documentation (https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html) would seem to imply this is possible with this statement:
You might also want to track these URLs, in order to update their
badges whenever their state changes.
The only ways I can imagine this would be possible (and most seem wrong) would be:
call setBadgeIdentifier:forURL from another application that is aware of the change
Launch a thread in the init function of my extension which listens for notifications and calls setBadgeIdentifier:forURL when it receives them
Call some OS API that prompts Finder that the extension should be triggered via requestBadgeIdentifierForURL.
Only the last one seems feasible, and could be managed via the extension informing the outside resource what needs refreshing via the beginObservingDirectoryAtURL/endObservingDirectoryAtURL callbacks, but i don't know what mechanism could do this.

Monitor which process and which user modified a file

I'm trying to solve a problem where an xml file gets modified.
I want to determine which process and user is modifying this file.
I was thinking of more like using Powershell to subscribe to a file modified event. Once that event occurs, it triggers some code which outputs the details about the file modification (time, user, process etc.) to an output file.
I tried using the FileSystemWatcher, but it doesn't return required info about the user/process which modified the file so that wasn't sufficient for me.
Does there exist such an event class which I could subscribe to which will trigger an event when the file gets modified and also return which user or process modified the file and when.
If nothing works, the last resort is using the Windows Security Audit Logs which generates events when the file was modified and I can use powershell to parse them.
Thank you!

Resources