matrix-org / matrix-appservice-slack

A Matrix <--> Slack bridge
Apache License 2.0
276 stars 72 forks source link

Slack Puppeting ("You have not enabled puppeting for this Slack workspace. You must do that to speak to members") #361

Open ErrorProne opened 4 years ago

ErrorProne commented 4 years ago

I believe I overlooked something or it is simply a documentation issue. When trying 1:1 DM I always get: "You have not enabled puppeting for this Slack workspace. You must do that to speak to members." Google gave me no, to me, meaningful results for puppeting and slack. I've greped through the code to find some hints where to enable what but I guess I know too little about slack.

Maybe you guys can give me any pointers? I would be happy to update the doc =)

chvp commented 4 years ago

You need to send a message in the control room containing oauth <your matrix id> true. That's what made that work for me, at least.

ErrorProne commented 4 years ago

Oh great, thanks! We havn't set up the oauth part at all. Sadly I've only access to the matrix server, but maybe the slack owner can figure the slack part out and hopefully we'll get some useful information out of this.

kupiqu commented 4 years ago

You need to send a message in the control room containing oauth <your matrix id> true. That's what made that work for me, at least.

Can you elaborate a little? I'm trying to do this but it doesn't seem to work. I must be doing sth wrong. By control room you mean the room that displayed the error "You have not enabled puppeting for this Slack workspace. You must do that to speak to members.", or somewhere else?

nicki-krizek commented 4 years ago

To enable puppetting and 1-1 conversations:

kupiqu commented 4 years ago

To enable puppetting and 1-1 conversations:

  • In the Matrix channel that has Slack integration, view a list of users
  • Start a direct message chat with Slack Integration user
  • Send message: login
  • Click the link and authorize the app on Slack

It worked great, thank you very much!

hlesueur commented 4 years ago

@charvp

You need to send a message in the control room containing oauth <your matrix id> true. That's what made that work for me, at least.

Where would you type such thing? Thanks for your help (the login on the slack integration bot fails for me)

chvp commented 4 years ago

Where would you type such thing? Thanks for your help (the login on the slack integration bot fails for me)

The message I posted is for self-hosted bridges.

kupiqu commented 4 years ago

To enable puppetting and 1-1 conversations:

  • In the Matrix channel that has Slack integration, view a list of users
  • Start a direct message chat with Slack Integration user
  • Send message: login
  • Click the link and authorize the app on Slack

I did this ↑ in riot-desktop 1.6.0.1 and it worked for me

hlesueur commented 4 years ago

yep.. for me it says image

(while it worked for other slack workspaces, it doesn't for the one I'm trying to link now)

kupiqu commented 4 years ago

yep.. for me it says image

(while it worked for other slack workspaces, it doesn't for the one I'm trying to link now)

Are you sure Riot as an app is enabled in that Slack workspace?

hlesueur commented 4 years ago

yes, it's installed. The bridge is working more or less. But when I try to link my own bot it fails.

kupiqu commented 4 years ago

yes, it's installed. The bridge is working more or less. But when I try to link my own bot it fails.

sorry, no idea. only thing I'd try is revoking the Riot app, and starting over

hlesueur commented 4 years ago

I did that already... Now it's all broken !! It no longer works... even the main bridge which was working

kupiqu commented 4 years ago

Now it's all broken !! It no longer works... even the main bridge which was working

Sorry to hear that. Unfortunately, it seems you have a new and bigger problem to fix before trying the puppeting thing again...

If my last advise wouldn't have resolved so badly, I'd suggest searching about Riot bridge reinstall problems in Slack and if you don't find anything meaningful then opening a new bug for that.

If you end up doing the latter, I'd also suggest being a bit more specific, "all broken and not working" can happen in many ways or mean different things.

One last (more speculative) comment, it may be that you need to restart the communication bridge with that slack workspace in Riot as well, but after the success of my previous suggestion, let me remind you that you decide or not to make these steps at your own risk. I am trying to help but there are no guarantees that this will work or worsen things even further.

hlesueur commented 4 years ago

thank you for your answer. Don't worry, I had done the step you suggested before you wrote your message :-)

I realize I did not detail here what I call broken because I dit it already in several places (chat). So to leave a trace of what happened: When I revoked the Riot_Bridge APP in slack and started over again from RIOT, I could complete the procedure as the first time, however the messages were relayed in the matrix => slack direction, but no longer in the slack => matrix direction ... and YES, the app bot was invited to the slack room.

Please, can you specify what you mean by "restart the communication bridge" ? When I removed permissions for the Riot_bridge app in slack, I put them back by starting over slack integration in RIOT. Is that what you meant, or is there another step I'm not aware?

kupiqu commented 4 years ago

That is what I meant, yes. However, given that you removed Riot_bridge app in slack, when you try this out in Riot, it should open the browser again like it did the first time, so slack accepts Riot_bridge as an app, just as before the removal.

Not sure this is what's happening, but it could be that this step is not done because Riot thinks Slack is on the other side, but actually it is not because you removed it. If so, I guess you will need to remove the slack workspace bridge in Riot too, and restart the communication from Riot.

It's likely you did this already, in which case I'm out of ideas :/

hlesueur commented 4 years ago

I think I understood the problem: upon removing and re-creating the app in slack, its presence goes to 'away' So the app no longer relays messages from slack

(EDIT) I could indeed repair the broken bridge by setting the bot app presence I'm not extremey sure how I did this because I tried several things to reactivate it, but I think I finally got it by:

seems like I need to open a new issue: https://github.com/matrix-org/matrix-appservice-slack/issues/413 BUT: I was still having the puppeting issue at the beginning, and it's not yet solved I still get this Integration Failed when I try linking my personnal bot from within the discussion with slack integration

It's weird because another user from my workspace could effectively link his bot. Which permission is badly set? How to debug?

freelock commented 4 years ago

I am successfully puppeted on one Slack team, originally done using the oauth command in the main command room. However, I'm getting the error messages noted above when I attempt to use a DM with the slack bridge to log into other Slack teams.

Is that what this issue is about -- puppeting on more than one team? If not, I'll file a new bug...

hlesueur commented 4 years ago

Hello @freelock I'm successfully puppeted to two slack teams, both with the slackapp on riot, but unsuccessfully to a third Unclear...

freelock commented 4 years ago

I just switched my bridge over from the "slack-v14-fix" Docker tag to the "stable" tag, and tried using the "login" direct message to my Slack user. This got me an authorization link, which let me pick a slack team to authorize. However, when I attempted to authorize, I got a page that says:

Integration Failed Unfortunately, your account did not go as expected...

... and the bridge logged this message:

Jun-14 16:38:34.375 INFO Main Handled $<event> (!<roomid>:matrix.freelock.com)
Jun-14 16:39:13.083 INFO SlackHookHandler Received slack webhook GET /<token>/authorize?code=<token>: {}
Jun-14 16:39:13.434 ERROR SlackHookHandler Error during handling of an oauth token: error: duplicate key value violates unique constraint "puppets_matrixuser_key"
    at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:581:48)
    at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:380:19)
    at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:116:22)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:302:12)
    at readableAddChunk (_stream_readable.js:278:9)
    at Socket.Readable.push (_stream_readable.js:217:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  length: 231,
  severity: 'ERROR',
  code: '23505',
  detail: 'Key (matrixuser)=(@john:matrix.freelock.com) already exists.',
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: 'public',
  table: 'puppets',
  column: undefined,
  dataType: undefined,
  constraint: 'puppets_matrixuser_key',
  file: 'nbtinsert.c',
  line: '432',
  routine: '_bt_check_unique'
}

... so this looks to me that there's still a schema-level problem with allowing a user to puppet on multiple teams...

auscompgeek commented 4 years ago

@freelock The schema was fixed in 1.4.0-rc1.

williamkray commented 4 years ago

what does it mean if i'm able to do all the setup for this, and running either the login or oauth commands always takes me to a functional slack page asking for authorization, but any endpoint they redirect to back on my appservice server throws a 404? I've quadruple-checked to make sure my redirect uri matches the endpoint the app is supposed to hit, but literally nothing i configure has a functional endpoint, despite the service actively listening.