Skip to main content

I’ve tried many versions of this but I can no longer search the slack API within a specific Channel and seems due to some encoding issue. This used to work but now fails to return any result if I do a search like “text in:#general” whereas just searching for “text” does work. 

 

Here is the exact working URL that returns results in Slack’s URL tester. Copying that exact query into the GET webhook URL with my auth gets a successful response but it is empy of messages. On Slack URL tester page searching for “and” in our #general channel obviously returns lots of results!

 

Slack Tester URL working returns results:

 

Fails to work in Zapier call - returns as if search is wrong - no results. 

 

I tried adding Content-Type  with url-encoded blah blah stuff but it changes nothing. I think url encoding is assumed. 

 

Hi ​@Akrause 

What is the link to the Slack API endpoint documentation you reference to configure the API request in the Zap step?


Here’s the slack Web API for search.messages

https://api.slack.com/methods/search.messages

And the ability to test input is on that same page. So I tested it on that page , it works and returns results then I copy-pasted the URL returned in the API tester and it returns no matches in the Zapier Webhook. So the only thing I can think of that how the URL encoding is being handled is not right. 

 

I do see the output “query” contains a plus sign where I input the URL encoded space value %20. This is incorrect it should NOT convert to a plus even though sometimes there is a convention where converting space to a plus can work.

 

if I search with that same plus for space change in the Slack APP it also fails, but replacing plus with a space does work. 

 

So on further reflection it’s pretty clear that the Webhook from Zapier is incorrectly adding formatting encoding in the backend that it should not be. 

 

This used to work a few months ago so I’m guessing some backend update made this change.

 

 


@Akrause 

Things to check/try…

Try using this Zap action: Slack - API Request

 


Review the search query syntax

 


Thanks, I can’t seem to make any valid query with Slack API request. I get not_allowed_token_type but I have Slack connected with my credentials. I get same error if I manually add an Authentication with a Bearer token to the field (same token that works in the raw webhook step). 

 

I really think Zapier is incorrectly converting URL %20 to “+” signs and it’s mucking everything up. 

I wish for debugging it showed the raw data sent to the webhook.

 

 


@Akrause 

Feedback from AI:

 


Yes, but I think the built-in Slack API Beta Webhook uses the built-in credentials for my Slack connection (that’s why on previous “setup” tab you input and use a shared connection). I don’t even send it an auth or bearer token at all.

That’s the difference between built-in slack API-webhook and the raw Zapier Webhook is that Auth is handled for you. 

I clearly have the correct Token type when I send Raw Zapier Webhook because I get search results returned.

 

I guess what I should be doing is using a Code-Step that sends a raw CURL webhook post…. Ya, I should stop trying to use Zapier stuff… 


Hi there ​@Akrause 👋

Just came across this thread and was curious—did you have any luck using a Code step?

If not, here’s how I managed to do it, in case it helps you or anyone else who finds this later:

You’re right about the authentication for the API Request action. I did some playing around just now and couldn’t get it working with an API Request either. It seems the auth connection it uses doesn’t have the specific scopes needed for that search.messages endpoint.

So then I tried using a GET webhook, instead of the Custom Request one you were using previously and put the query into the Query String Params section instead of adding it to the URL. For the authentication I used a User token that specifically had the search:read scope that the search.messages endpoint requires:

da51a37a7ebf14c4dbe2adfa97f53c7f.png
And that was able to successfully load the messages that matched my search query:

f24e8391b8529da352903a3df200616b.png

If you give that webhook setup a try and it has an error that mentions the token, head over to the Your Apps page in Slack, select your app then go to OAuth & Permissions.

Under the Scopes section, make sure it’s got the search:read scope added:

7c101c1d3f8b624af808b3a78386fa4c.png

Then scroll back up the page, and reinstall the token to your Slack workspace:

edf647cac5a6febb59ea002ab75d714f.png

And test the Webhook action again.

Hope that helps. If you give it a try and get stuck, or you found a different solution please let me know—want to make sure you’re all set here!