I have an app that connects with several platforms: Teams, Slack, Google etc.
I want to allow my users to add connections to their existing accounts: for example, if they are Slack only, allow them to connect teams into their same account on my platform.
For all other platforms, I can do this as follows:
Take the application URL (e.g. Slack)
Append a parameter state, with their ID on my platform e.g. SLACK_URL?state=${user.id}
When I then process the connection, the state parameter is supplied as part of the callback from the connected service, and I can identify the relevant user and connect to their account.
Is there a similar process for Teams? I've tried doing the same with the state parameter, and no dice, it doesn't seem to work
How the users connect:
Slack
We present a button that allows the user to authorise with Slack
In the URL of that button we set a parameter state with the users ID
When Slack is authorised, it calls back to our API, and passes that state value along
We then use that to identify the user account the new authorisation belongs to
Teams
We present a button that brings the user to the application install URL in the Teams app store
The user clicks that and goes through the installation process, adding the app to a channel of their choice
What we would like to do is the same as the Slack URL, set a state value with the users ID, and have that passed back to us on the initial installUpdate or membersAdded event from that channel.
Essentially what we'd like to do when connecting a users Teams account is set some metadata on the URL that they use to install the app, and have that sent back to us so we can identify the installing user.
This is common in OAuth flows, you set a state parameter with whatever you want, and that state is passed back on authorization.
Related
I have a Bot service and a Node JS client that uses the open-source Web chat control. My requirement is that I need to store some user information(like userId) in a browser cookie and send this information to the bot service, so that when user returns to the bot he/she doesn't have to enter user information again. Is there a way to support this requirement with the Web-chat control and Bot service?
My requirement is that I need to store some user information(like userId) in a browser cookie and send this information to the bot service, so that when user returns to the bot he/she doesn't have to enter user information again.
It seems that you’d like to store user information in cookie to remember information about the user and pass user’s specific information to bot service. To store/retrieve user information in cookie, you can create/read cookies via the document.cookie property with JavaScript in client side code.
To pass user’s specific information to bot service, as Nicolas R mentioned in comment, you can send specific event activity with user information via backchannel mechanism. You can get more information about the backchannel mechanism from these articles:
Use the backchannel mechanism
The Backchannel
So I'm building a small Slack bot that I want multiple users to be able to use in different Slack teams. So far the workflow is like this:
User signs up on website.
User connects with an API provider and receives their OAuth credentials. The access token for each user is saved in the database.
User adds Slack bot to their team.
With hardcoded API values the bot retrieves the desired data, but what is the best way for the bot to be able to get the appropriate data for each Slack team?
I obviously don't want a user to need to keep signing into the website etc, so how do I associate the slack team with the Laravel user and then pull the relevant API data?
For some example code, imagine that I have a Strava access token stored in my DB for a user and I want to call the API:
$botman->hears('runstats', function ($bot) {
$payload = \Strava\Account::get(
\Auth::user()->strava_id,
array('api_key' => "here_is_a_secret_key")
);
$bot->reply($payload->monthly_kms);
This works fine when I query from my web interface as I'm signed into my website and it spits back 123km as an example.
Obviously when I'm signed into Slack then there's no Auth::user instance and so it cannot find the relevant Strava ID. That's what I want to be able to retrieve for the relevant Slack user. I envisage it being installed in multiple Slack workspaces.
You need to store the relation between a Slack user (with team ID, user ID) and his individual token for each API in your database.
So you have two options when adding new API tokens:
Ensure that the process of adding new tokens for API services is always started on Slack (e.g. with a slash command) and then forward the user to your webpage. Thus your app knows which user it is.
Let users log into your web-page with their Slack credentials (using Slack Sign-in).
Both options require that your Slack app has been previously installed to the relevant team of course.
I an developing a chrome extension which doesn't has any sign up or sign in flow, instead depends on authentication of a separate web app. I started integrating mixpanel and tracking user events anonymously, Now i want to identify those anonymous users using "alias" and "identify" api. I have a user_id for identifying users from the web app exposed REST api. Now if i apply a boolean check and make sure i call mixpanel "alias(user_id)" once and call "identify(user_id)" every time user visits a page, I can see a user entry in explore tab of mixpanel but live events tab has a anonymous user with same user_id and its tracked data, I wish to link such anonymous users with appropriate user profiles.
Please help me with this if you have some understanding of mixpanel. I am new at this.
Since I didn't had a sign in or sign up flow, I cannot use
mixpanel.alias
Hence i am now calling
mixpanel.identify
As soon as user installs the plugin, Since "identify" api can be called any number of times for an user, We are able to track all future events as soon as plugin gets installed.
This way by not letting the user generate anonymous events we can handle such situation.
In messaging platforms like Slack and HipChat you can integrate apps that can post messages to groups without them being sent from a user e.g.
Defect Management System: A new defect was logged at 12pm
Instead of:
John Smith: A new defect was logged at 12pm
Is it possible to do the same thing in Yammer?
There are two options available for you:
1 - You can create a new user on Yammer, name it however you want (e.g., "Defect Management System" with a snazzy avatar), then take the user's OAUTH token and use it to impersonate that user programmatically. This is fine for quick development.
2 - You can create a new user on Yammer, name it however you want, then register a new app on Yammer to get a permanent token and client ID, then use those to impersonate that user programmatically. This is the right way to do it. You can read more about how to do this on https://developer.yammer.com/introduction/#gs-registerapp.
This is an example of a user that we impersonate. It is a bot on our network. It is a separate account in AD and is registered as an app in Yammer and interacts with Yammer automatically.
You are always impersonating a user in Yammer via the API, there isn't a way to impersonate a group, in the way that Slack does (i.e. being able to override the username displayed and replace it with a bot for example in your payload)
If this app is for internal use, you could consider creating a dummy user as a bot to post defects, and then using Custom Object Types & Actions in Open Graph to further customize the messages. Obviously there are some business & administration considerations in doing that, not just development ones.
I am building a web based chat application using strophe and ejabberd. What I am trying to do now, is :
A user can anonymously log in into the chat application and after he log in there is automatically an admin assigned to him. So far, I had managed to enable anonymous log in ejabberd, but I have to manually add the JID of the admin. So my question is how do I assign a random admin to the user?
What you would need to do is always start a chat with some user (the same user for everyone) and demultiplex the messages on that user's side. You can do this using a BOT. What this will allow you to do is that at times of higher activity, an admin can serve more than 1 user.
Alternatively, you can also set up a web-service which returns the JID of the next available admin in the queue. Whenever an admin is done interacting with a user, [s]he will have to signal her/his availability on some web-interface (or you can use chatstate notifications for this - for example, window-closed).