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.
- It doesn’t appear to be possible to use this in place of the OAuth approval flow in the Zapier Editor
- 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?