Unfortunately neither of those things are possible at the moment.
Hello there, I am currently setting this up, and I am not sure if the interface changed or not, but are these scopes setup under Bot Token Scopes or under User Token Scopes?
Thank you.
Both of these things should be possible using Zapier integration. Less than ideal, I know, but since Iâve been looking at it as a workaround for this plugin I thought Iâd share.
Hi there!
I tried to configure the plugin as explained in this thread but when I try to post a transcript I only get from the slack bot:
âLoading the transcriptâŚâ
My Discourse is hosted in the âdiscourse.groupâ subdomain. This is what I get from the error logs:
/var/www/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/slack/slack_command_controller.rb:86:in `block in process_post_requestâ
/var/www/discourse/lib/scheduler/defer.rb:94:in `block in do_workâ
rails_multisite-2.1.0/lib/rails_multisite/connection_management.rb:252:in `with_connectionâ
rails_multisite-2.1.0/lib/rails_multisite/connection_management.rb:61:in `with_connectionâ
/var/www/discourse/lib/scheduler/defer.rb:89:in `do_workâ
/var/www/discourse/lib/scheduler/defer.rb:79:in `block (2 levels) in start_threadâ
Do you know how to fix this?
Where the error is occurring indicates the Slack credentials entered on your site settings page are not correct. To find your Chat Integrations settings, go to your Admin / Settings page and scroll to the bottom of the left-side menu. You will see a âChat Integrationsâ button at the bottom of the list.
On that settings page, make sure that the following settings are correct:
chat integration discourse username
chat integration slack access token
chat integration slack incoming webhook token
Let us know if that doesnât solve the issue. Since your site is hosted by us, we can have a look at what is going wrong.
Solution for Errors:
1) DiscourseChat::ProviderError
2) {\"ok\":false,\"error\":\"not_in_channel\"}
Trying to make this more obvious because it was unfortunately difficult to find the answer. The Slack App creation process has changed a bit since these instructions. And it seems the actual integration of the bot with a channel in Slack takes a bit more setup as well.
From my Slack workspace, I could confirm the app was working by DMâing the bot @discourse
as well as the running commands /discourse
. But from the Discourse Plugin settings, I was receiving errors and could not set a channel nor send a test message.
How to implement
EDIT: there is updated information in the replies below. Iâve attempted to incorporate the additional steps here as of 4/6/20. Please comment or modify these as needed. - dp
- Bot permissions:
chat:write.customize
permission needs to be added in order for the /discourse post slash command to work. I also addedchat:write
. - Youâll need to create the channel in Slack. And then either run the
/discourse
commands from the channel or set up a rule in Discourse. - You need to manually add the bot to the channel of interest (at least to post a transcript)! You can do this in the private conversation with the bot in slack:
"conversation settings" > "add this app to a channel"
. - Then, importantly, you need to add the discourse bot user to the channel. I could not get this to work through the normal channel âadd userâ or âadd appâ buttons. BUT I was successful by sending a message to â@discourseâ within the channel â I was then prompted by slack with the message â@discourse is not in this channel, would you like to add?â
- I could then run a test message successfully from Plugins settings
Note: in the Slack app setup I set the App name to @discourse
Thanks @thedavidprice and @simon for your great support!
Iâve fixed the issue! Everything was fine but the bot needed to be added to the channel to post a transcript. Maybe you can add this point to the list of instructions above?
Another thing I noticed is that the chat:write:bot
permission scope is not available anymore, you have to chose chat:write
!
Hi @Vincenzo_Lomonaco, to confirm, you are saying the Plugin itself will now add the bot to the channel (for example, when creating a rule)?
Indeed, it seems a lot has changed on the Slack setup side of things. I can confirm I added chat:write
. I also added chat:write.customize
.
Once created via Slack API, it wasnât clear to me if I needed to also add the app to a channel within my Workspace settings for Apps. In my case I did chose a channel.
Lastly, I also had some confusion about whether or not I needed to add âDisplay Informationâ on the app settings page of Slack. I did, which seems to be the information used within Slack app directory and for âRecent Appsâ in Slack left column. My image url I entered within Discourse for the bot messages does not seem to be working. The name of the bot is working.
Thanks again! Overall very happy with how things are going.
Hi @thedavidprice,
No, you need to manually add the bot to the channel of interest (at least to post a transcript)! You can do this in the private conversation with the bot in slack: "conversation settings" > "add this app to a channel"
.
Thanks for doing this. I have updated the guide based on your post and my own testing. I can confirm that the chat:write.customize
permission needs to be added to the Bot Token Scopes setting in order for the /discourse post
slash command to work.
I thought that the channels:join
scope might be all that is needed to allow the bot to automatically join a channel, but based on my testing this does not work. I think the easiest way to add the bot to a channel is now outlined in step 15 of the guide. If there is a better way to do it, please let me know.
Iâll clean up the replies in this topic in a few days, once we have confirmed that the current state of the guide is working for people.
Hey folks, Iâm looking to get this configured for a place that has some tighter security restrictions. In reviewing the required scopes documented in the OP vs. what is currently allowed, this is what I see:
chat:write # ? unclear, but chat:write:bot is OK
chat:write.customize ? unclear, but chat:write:bot is OK
users:read # X rejected
channels:history X rejected
groups:history # OK, cautiously accepted
im:history # OK, accepted
If the app were only configured with the following scopes, what would work and what would be broken?
chat:write:bot
groups:history
im:history
For example, I would be OK giving up transcriptsâŚ
Itâs been a while since I first implemented this, and it looks like slackâs scopes have changed a lot since then. I see people have been keeping the OP wiki up-to-date, which is great!
I think that chat:write:bot
and chat:write:user
have been deprecated in favour of chat:write
.
It looks like chat:write.customize
is required because we customize the messageâs author_name and author_icon to match the Discourse user.
The users:read
and *:history
scopes are only used for the transcript posting. I realise it seems like a lot! But fundamentally Discourse needs access to your chat history in order to build the transcript. If youâd rather not grant those permissions then it should be totally fine to skip them, and continue without transcript posting.
When I use slash commands, I get this error: /hub failed with the error "dispatch_failed"
(We use /hub
instead of /discourse
)
I have been able to add the app to the channel. Iâve also been able to send a test post from Discourse to our Slack, but I havenât been able to figure out the /
commands. Iâd love some help troubleshooting!
Can you check the permissions that you have added to the app on Slack? The last time I tried configuring this, all the permissions from steps 5 and 6 of the guide needed to be added to the Apps scopes:
chat:write
chat:write.customize
users:read
channels:history
groups:history
im:history
Let us know if that doesnât resolve the issue.
I believe I do have the correct permissions. Hereâs a screenshot of the settings I have under Bot Token Scopes.
What do you think? Unfortunately that means something else is going on.
Iâve gone through the setup guide again and created a /hub
slash command. Calling /hub post
is working for me on any channels that Iâve added the app to. I am using the same permissions as in the screenshot that you posted.
Can you make sure youâve completed step 8 of the guide? That section tells you to:
Go to the Interactivity & Shortcuts page, enable the Interactivity section by switching it to On and enter this url under âRequest URLâ
<your-discourse-url>/chat-integration/slack/interactive
It might also be good to confirm that you can post from Discourse to the Slack channel that youâre trying to run the /hub post
command on.
Let us know if youâre still not able to get this to work.
I checked and I believe yes, I did follow that step.
Hereâs a screenshot.
I think the error is happening in something related to Step 7, though.
Here are my settings.
How that shows up when I try using the slash command on Slack is
Yes, that part is working perfectly.
Nope, not working.
The âRequest URLâ in the Edit Command section of your screenshot isnât using HTTPS. Maybe thatâs the problem.
That did it, thank you!!!
Iâve followed the instructions in this guide and have my Disourse/Slack integration (mostly) working. Great work on this plugin! I do have three questions/observations.
Canât subscribe to messages in a sub category by subscribing to the parent
This may be by-design, but it wasnât obvious at first. I have parent categories with child categories under them. I expected that if I created a rule that filtered âAll posts and repliesâ to the parent category that it would implicitly include each of the children categories as well. This did not seem to work however, and I needed to create rules for each of my (many) child categories. This would be a great enhancement request to simplify setup for a Discourse installation with many sub categories under a few parent categories.
Canât subscribe to all categories with a single rule
I found some conflicting information on this and I assume the older Slack plugin allowed for this, but I couldnât find a way to create a single rule that would simply subscript to all posts and replies from ALL categories in the site. I was hoping to do this all in a single, simple rule. But due to this and the point above, it took 31 separate rules instead of a single rule to just get a basic bridge between my entire Discourse platform and a Slack channel. Unless Iâve missed something, please consider this as an enhancement request as well.
Discourse post command only works in one channel
Now, this is likely my fault, but I canât figure it out, Iâve been through all the threads on the topic, and Iâd love some help. Iâve checked and doubled checked the permissions of my Slack app and I can confirm that it totally 100% works⌠in only one of my channels!
/discourse post 20
So I know the access token is set up and working fine. However, in all of the other channels in my Slack team, the command above simply outputs
Loading the transcript...
and thatâs all. These are all public channels and Iâve tried every manner of combination of settings. The one channel that works was created newly today, but when I created another new channel to test, it didnât work. I donât even know where to begin troubleshooting this. The only logs Iâm aware of in Discourse are
./launcher logs app
but there doesnât seem to be anything at all there. What setting may I have overlooked that would only allow posting to work in one channel, and where would I look to debug this?