Hi there,
How would we be able to include file/images in Google Sheet when a message is pushed to Zapier from Slack?
The idea is to push these messages to Zapier and it will be added as a row in Google Sheet.
Thanks heaps
Hi there,
How would we be able to include file/images in Google Sheet when a message is pushed to Zapier from Slack?
The idea is to push these messages to Zapier and it will be added as a row in Google Sheet.
Thanks heaps
By default, slack does not include an image when pushed to Zapier. However, since you are hoping to trigger only pushed messages there is a quick manual step you can take before pushing the message so that the image in the message is publicly accessible.
Before pushing the message/image, hover on the the dots on the image and select “View external link”, copy the link, then when you go to push the message/image to zapier you can paste in the public view link to the image in the additional text box. You can then map this url to a cell in google sheets ( you will be mapping the ‘text_added’ field from the trigger step)
*****ADVANCED****
However, technically, this link is just to an html page that contains the image. If you wanted to map the image itself into the google sheet it gets more advanced and will involve a code step.
I am trying to do the same thing but instead of adding an image from Slack to Google Sheets I am wanting to add it to Asana. Can you elaborate on the coding needed to map the image itself rather than the html page?
Hi
It seems like you can right-click on the “Open in browser” link then on “Copy Link” to get a direct, public, link to the image:
For example, copying the link to the browser screen in my slack gives me this url: https://files.slack.com/files-pri/T01KBBEGM9D-F020161BHBL/screen_shot_2021-02-03_at_5.51.55_pm.png
which when sent in a gmail step fails to populate as an attachment (makes sense, considering this link is private and requires you log in to view)
However, the public version of that file location would be https://files.slack.com/files-pri/T01KBBEGM9D-F020161BHBL/screen_shot_2021-02-03_at_5.51.55_pm.png?pub_secret=86e0137c9e *note the secret that slack appends to the url when viewing the image link from the external file url.
A sort of webscaper would need to be hacked together using a code step to make a request to the external file link and then parse out the image location. Something like the below.
const request = await fetch(inputData.url, {
method: "POST",
});
let html = await request.text();
var image_file_location_start = html.substring(html.indexOf('content="https://'));
var image_public_url = image_file_location_start.substring(image_file_location_start.indexOf('"')+1,image_file_location_start.indexOf('">'));
return {image_public_url}
The code will return the public url which you then can try mapping in the Attach File Asana action.
*Note the above is extraordinarily advanced and there may likely be better (less hacky) ways to accomplish this using the slack API. The above also only works if the only thing you put in the additional text box is the external link you’ve copied. It does not account for finding the project or the task to attach the file to
This is so wonderful thank you so much for the in depth explanation. I had been trying to use the link
No problem! Let me know if you have any questions, the code will be difficult to test as you won’t be able to test it in “test” mode since you won’t have a url from the trigger step. you’ll need to set everything up, then turn the zap on to test.
To get around this, you can do 1 of two things.
First Way:
Copy an external link from slack, paste it in manually in the code input, run the code, map the value in the asana step. Then go back to the code block and replace the url input with the dynamic info from the trigger.
Alternate Approach:
Skip running the code step & try to map the “pill” in the next step using {{123157881__image_public_url}} . You will need to replace 123157881 with the node id of the code step in your zap. If you click on the code step, you will see that value populated. More on this type of stuff can be found here:
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.