I've set up my slack app to be installed using Oauth2.0 successfully calling
https://slack.com/oauth/v2/authorize?client_id=<myAppsClientId>&scope=chat:write,commands,incoming-webhook,users:read&user_scope=chat:write,users:read
but when i try to use Sign In With Slack (So user can manage their slack on my web app) I use
https://slack.com/oauth/v2/authorize?scope=identity.basic,identity.avatar&client_id=<myAppsClientId>
The user gets the error on the slack url (before being redirected to my app):
Error details
Invalid permissions requested
Invalid scopes: identity.basic, identity.avatar
Since the add to slack and sign in with slack both call the same uri, im assuming the scope params are what separate the two. Not sure where Im going wrong because I followed the docs and used the button they generated for me.
I don't know that this is the correct fix, but I encountered the same issue and I was able to get it working by renaming the 'scope' parameter to 'user_scope'
Ok I actually was able to get it to work by NOT using v2 for Sign In With Slack. But I HAD to use v2 for Add to Slack.
So using /oauth/v2/authorize and /api/oauth.v2.access for add to slack
and /oauth/authorize and /api/oauth.access for signin with slack
I don't think it should work like this but it's the only combo that's working.
I'm starting out with the Slack API and trying to just get a list of messages.
Here are my steps:
Created a Slack app and gave it channels:read and channels:history scope (also re-installed it)
Queried the list of channels with conversations.list (this worked fine)
From the output of conversations.list, I found a channel that I use and copied the id
Used the conversations.history api with the channelid from step 3
Result:
{ "ok": false, "error": "not_in_channel" }
I'm not at all sure what is happening here. I definitely have messages in the channel, and the documentation page for that api does not say anything about this "not_in_channel" error code.
What am I doing wrong?
After a long time of investigations (~2 hours), I found an easy approach. For Caleb's answer, I didn't understand how to invite a Bot to the channel. Hence, I am posting this answer.
Go to your Slack Channel and type the following as a message.
/invite #BOT_NAME
Eg: If your Bot name is SRE Incident Manager the command would be as follows.
/invite #sre_incident_manager
As soon as you start typing #, Slack will automatically suggest. So it becomes easy. For this, the Bot needs to be added to your Slack Workspace.
PS: Original answer.
The error not_in_channel has the exact meaning, your custom Slack app should be added to the channel.
Exact solution 1
To resolve the error, in the Web Slack interface:
Open channel settings
Click on the Integrations tab
Click Add apps and find your custom app.
Slack app might have different interface, see Iryna Vernik's answer.
Alternative solution 2
Give access to the bot to all channels by adding workspace wide scope, for example, chat:write.public. Depends on your needs and security requirements.
Alternative solution 3
To access the channel chat from API specify Incoming webhook. Slack will generate a unique URL with the token per each channel. Only convenient for a few channels.
This error arises when you are using the bot oauth token and the bot is not invited to the channel. To solve this you need to
Invite the bot(slack app) to join the channel.
Use the OAuth Access Token instead
To add Bot to your channel you need to write /invite #Bot_name in the slack channel
I also didn't understand how to invite a Bot to the channel. Way that was proposed by Caleb and Keet was not clear for me or not working. From my side, 'invite' work after
open channel
in Details tab, choose a 'More'clause
in dropdown menu, chouse an 'add app'
in pop-up look for you app (bot)
Also i was use Bot User OAuth Access Token, because i need this functionality in private channel (additionaly, you should add for bot groups:history scope)
FOr me, instead of invite a user/bot, I invite the app.
I'm getting started with the Slack API as well, and I've come to realize that not_in_channel simply means that the user/bot you are using the token for hasn't joined that particular channel you're trying to perform an action on.
Think of it this way: if you're using Slack on the web-browser or web-app, you wouldn't be able to post a message on a channel you haven't either joined or was invited to.
☝️ You'll also never run into this issue through the Slack UI/UX because you're not even able to access the channels UNTIL you are invited or join it.
Click to see png example of a slack message stating my bot being added to a channel
However, because we're using the API we can essentially skip some steps, and in this case we skipped the step where a user/bot has joined the channel before doing the action we're trying to perform (writing a message, grabbing information, etc).
💪 How to address this
There's probably plenty of ways to do it that I'm not versed in, but if you're just concerned about a specific channel or two without the concern of scaling to x channels I'll list the way that worked for me.
📇 /invite Slash Command
As others have mentioned, putting /invite in the message box lets you use Slack's slash command shortcut to add users. What's important is this way also allows us to invite bots to the channel.
Putting "#" triggers Slack to start auto-suggesting, which is why it then becomes easy to find your bot name in the list.
Click here to see screenshot example of the /invite command with #bot_name_here
Hope this helps answer people's question on why it's happening, and thank you to the original posts that got me out of my initial mess. 🙏
As all others said, you need to join each channel.
The bot can join channel programmatically by using API below:
https://api.slack.com/methods/conversations.join
Don't forget to add permission of conversations.join
Is it possible to craft a t.me URL that prompts the user to send a specific message to a specific bot. The closest I've found so far is t.me/share/url?url=my%20message, but that doesn't specify a username so the user has to choose one. I don't see the t.me URLs documented anywhere.
Note: this is not the same as sending a message via the API.
You can use deep linking to bot, use following format like this link:
https://t.me/username?start=<token>
Your backend will receive /start <token> . The user however will just see normal
/start
on their chat window.
I'm attempting to create a new slack command integration that when invoked will fetch a unique set of data for the user. I have the integration working, however the data returned is displayed within slack as a "BOT".
Ideally, the integration will be similar to Giphy. When the /giphy command in slack is invoked, an image is returned that is appended to the user's message. I'd be curious to know how they did this. As far as I can tell, Slack integration APIs only allow responses to be sent as BOTs not as a user or appended to a user's message.
When responding to a slash command with a string that includes a channel ID like <#C3989289>, the response in Slack shows a deep link to that channel "#general.
When I do the same for a direct message or IM, the response in Slack shows "#deleted-channel" and it's not a link.
I don't see anything in the docs about why this: https://api.slack.com/docs/message-formatting#linking_to_channels_and_users
Slack has confirmed that their system is designed in this way to protect private channels/direct messages from being made aware to users, even if the recipient of the message containing the deep link does belong to that particular channel/DM.