So, let's say I have the following use case - I have service A and I want to perform a certain action associated with service A in slack. But for that, I must first log in to service A and bound the accounts of slack and of service A.
Following is the basic documentation I found out about it.
https://api.slack.com/best-practices/blueprints/account-binding
We will have the following components -
Following is the basic documentation I found out about it.
https://api.slack.com/best-practices/blueprints/account-binding
We will have the following components -
- User
- Intermediate service - X
- Slack
- Service A
So, the following steps should be followed when this is done.
- The user invokes an action related to service A.
- If logged in and authenticated already, alright.
- If not, It will need to do so again. For that, it goes to intermediate service, check if binding exists. If yes, good to go.
- If not, it will create a token, send it to service A along with a request to authenticate.
- User logs in to service A and return user id for service A user along with the token.
- Then this token will be looked up and then user id for service A will be stored against slack user id.
- Binding is successful.
Now, some points to consider, This makes the assumption that it is okay to just authenticate once and to invoke any action service A, we will not need to authenticate again and again.
Now, let's consider scenario 2.
We have service A and Service B and slack admin can choose which service should be used to do so. and once chosen it is fixed and all users from that workspace will automatically use that service to authenticate. Except for the addition to the previous scenario is, we always need to have a session to invoke action to service B.
At first, let's see how to fix which service will be authenticated for which workspace.
Let's say in service A and service B we can provide a way to give the option to install the app.
Since the request will be coming from each individual service, We can add a parameter state with values 'A' or 'B' with it. And this can be returned to the oauth2 URL. There, along with team id and workspace, you can read value State as well.
So, in summary,
1. State (optional) parameter while making this call.
2. use 'A' or 'B' as value there.
At first, let's see how to fix which service will be authenticated for which workspace.
Let's say in service A and service B we can provide a way to give the option to install the app.
Since the request will be coming from each individual service, We can add a parameter state with values 'A' or 'B' with it. And this can be returned to the oauth2 URL. There, along with team id and workspace, you can read value State as well.
So, in summary,
1. State (optional) parameter while making this call.
2. use 'A' or 'B' as value there.
We will have the following components -
- User
- Intermediate service - X
- Slack
- Service A
- Service B
Now, this should follow the same flow. Except we need to do either of the following steps for service B.
- We add an extra way to make a session persisted in service B and use that way.
- We store user password in service X upon authentication
- Since, 2 will need extra space, instead of checking if the slack user has community id, it should authenticate and check-in service B if we have a slack user ID. Assuming you can store that info there. But this will still anyways need a way to log in, have user id and password stored already and check for that particular user, right? So, to really avoid doing so, we can use the admin user or create one role on the community side and use it so we can lookup user id and then associated slack user with it.
- So, we need to store only admin credentials in service X and then make calls using that. No need to store all user id and slack id in service X. just store service X in community side.
So, finally proposed solution -
1. Use the 'state' parameter while installing to know which service is used.
2. Store admin credentials of service A and service B to know about whether the user has logged in at least once when a request comes from slack.
3. When you want to post things from community, you can just check if community user has associated slack id. If yes, then make an associated calls and post the notification.











