Skip to main content

Hey team,

TLDR; I want my Zapier to perform an action in Slack that isn’t possible with the out-of-the-box Zapier/Slack scopes. How can I achieve this?

As part of my Zapier flow, I want to add a emoji reaction to a message. This isn’t provided by the Slack application, so I create a Custom Action. No problems. Here’s the code it’s generated as my custom action:

export async function addEmojiReactionToSlackMessage({
channelId,
messageTimestamp,
emojiName,
}: {
channelId: string;
messageTimestamp: string;
emojiName: string;
}): Promise<{ result: boolean }> {
// Define the API endpoint URL
const url = 'https://slack.com/api/reactions.add';

// Prepare the request body with the required parameters
const requestBody = {
channel: channelId,
name: emojiName, // The emoji reaction to add, provided as input
timestamp: messageTimestamp,
};

// Make the API request using fetchWithZapier
const response = await fetchWithZapier(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});

// Throw an error if the response is not ok
await response.throwErrorIfNotOk();

// Parse the JSON response
const data = await response.json();

// Return the result indicating success
return { result: data.ok };
}

When I run the action, I get the following error (emphasis added): 

kemit:log] {"message":"Relay Response","data":{"status":200,"requestId":"4f7fd502-48b5-4a9f-a4fa-72b4afa81efa","text":"{\"ok\":false,\"error\":\"missing_scope\",\"needed\":\"reactions:write\",\"provided\":\"identify,channels:history,groups:history,channels:read,emoji:read,files:read,groups:read,im:read,mpim:read,reactions:read,search:read,stars:read,team:read,users:read,users:read.ema"}}

"emit:data] {"result":false}

exit code: 0

The Zapier app by default doesn’t request the reactions:write scope when installed into Slack, so the error is understandable.

I have looked at and discarded the following options:

 

Extending the scopes requested by Zapier app on install into Slack

I can’t see how this is even possible. The scopes appear to be fixed. Have I missed something?

 

Using a separate Slack App and tokens with the right scope

I created a new Slack App with the reactions:write scope and generated OAuth tokens.

  1. It doesn’t appear to be possible to use this in place of the OAuth approval flow in the Zapier Editor
  2. I tried using the OAuth token in the Custom Action as a Bearer token as discussed here, but no joy. Get the following error
lemit:log] {"message":"Relay Response","data":{"status":200,"requestId":"5c8b8abd-b05c-4df6-afb3-298ce6ac0692","text":"{\"ok\":false,\"error\":\"invalid_auth\",\"warning\":\"missing_charset\",\"response_metadata\":{\"warnings\":t\"missing_charset\"]}}"}}

eemit:data] {"result":false}

Any suggestions for how to achieve the above?

Hi ​@hannahg, welcome to the Community! 🎉

It’s not currently possible to change the scopes used in a Custom Action. So I’d suggest contacting our Support team to submit a feature request for the ability to set additional scopes. You can do that here: https://zapier.com/app/get-help

In the meantime, you could try using Webhooks instead of a custom action, as outlined in that guide you referenced:

You’d need to follow the steps to first create an app in Slack then, you’d need to select the reactions:write scope under User Token Scopes:

d1df07da4c565dc3c9c4e713f75e3d7a.png
I just tested this with a POST (Webhooks by Zapier) action that was set up like this:

649b1d27d081fe4731bd14e8ed22e5d9.png
And it was successful in adding a reaction:

4b11272709b338932b80b749150c9a21.png
fb913c89d36536e6e3f072740b9c3aa5.png

I know it’s not an ideal solution but hopefully it’ll help to get things up an running in the meantime.

If you do give that approach a try do let me know how it goes. Happy to assist further if you get stuck at all! 🙂