Overview
A key benefit of Vortex is that updates to your invitation flows generally don’t require any involvement from developers. Developers do play an important role though, and you’ll need an hour or so of their time to handle the initial implementation. The work will touch both your frontend and backend services. A typical Vortex installation involves the following steps:- Install a Vortex language-specific SDK appropriate for your backend service.
- Create a JSON Web Token (JWT) to enable secure communication between your service and Vortex.
- Add a snippet of code to your client to render the invitation form.
- Make two API calls that bookend your registration process, one prior to registration to get the invitation details and one after registration to mark the invitation as accepted.
- If a new template variable is added to your email templates, the
templateVariablesparameter in your client code snippet will need to be updated to include it. - If the Google contacts import is enabled, you’ll need to create a Google application and include a client ID in the code snippet.
- If Autojoin is enabled, you’ll need to make an additional API call during your registration flow and add an interface for your customers’ admins to manage their list of allowed domains.
JSON Web Tokens
JSON web token (JWT) is an open standard that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. JWTs can be signed, which means you can be certain that the senders are who they say they are. Additionally, the structure of a JWT allows you to verify that the content hasn’t been tampered with. JWTs consist of three parts - the header, the payload and the signature. While it’s up to you to determine when you’ll generate the JWT, ideally you would generate it on-demand when the invitation widget is rendered. This limits the amount of information that you’ll need to include in the payload. The Install Backend step on the Installation tab in your invitation flow will guide you on how to create a JWT using one of Vortex’s SDKs. However, if your language isn’t supported you use the steps below.Generate a JWT
Generate a JWT
The following steps outline how to create a valid header, payload and signature.
1
Derive the signing key from the API key itself
2
Create the header and payload
The header has the following type:The payload contains identifying information about the current user (i.e., the inviter), and includes the following required fields.The JWT payload consists of:
userId- Your internal ID for the current user.userEmail- The current user’s email address.adminScopes- Identifies capabilities that are generally limited to people with admin-type priviledges. Currently the only option is “autojoin”, which allows the given user to enable the Autojoin feature.
3
Base64 url encode the header and payload
4
Generate the signature and create the JWT
The signature is a string that verifies the integrity of the data in the payload between Vortex and your service.
5
Use the JWT when rendering an invitation widget
Be sure to not expose your API key. You can either embed the JWT as part of the page sent from your backend or even create an endpoint to fetch it on demand. However you present the JWT to your frontend code, ensure the API key is not exposed with it. Also ensure that the JWT you expose to your user is the JWT that identifies the user that will use it.
Client Code Parameters
The Install Client step of the Installation tab provides details on the minimal set of parameters you’ll need to pass along via the code snippet. AlthoughcomponentId and jwt are technically the only required parameters,scope is effectively required for most customers and there are other parameters detailed below that you will more than likely need to populate.
componentId
required An invitation flow’s ID can be found on the Installation tab, in the code snippet in the Install Client step.jwt
required Use the JWT generated per the instructions in the JSON Web Tokens section.scope
required for most customersscope is the internal identifier of the grouping to which the invitation applies. Although some services have invitations that simply establish connections between users, like a social network, most other services, especially B2B services, have invitations that are specific to some type of grouping of users. For example, on Slack and Trello you get invited to a workspace. On Airbnb you get invited to a trip. And if you play fantasy sports, you get invited to a league.
If Slack were using Vortex, scope would be the internal ID of the workspace.
scope parameter.
scopeType
Your service may have multiple groupings. For example, Trello has workspaces, but also has the concept of boards that are owned by a workspace. People can be invited to a workspace, but they can also be invited directly to a board. If Trello were using Vortex,scope would represent a workspace ID for invitations to a workspace, or a board ID for invitations to a board. Unless Trello’s workspace and board IDs were of a format such that it was inherently obvious which type of entity they applied to, Trello would use the scopeType parameter, setting it to either “workspace” or “board” as appropriate.
userEmailsInGroup
If the number of members in a group (as defined byinvitationScope) isn’t large, you can send them all via this parameter so that Vortex can validate that the person being invited isn’t already a member. If the number of members is too large to pass all of them in here, use the subsequent emailValidationFunction parameter instead.
emailValidationFunction
For large groupings, where sending all members inuserEmailsInGrouping isn’t practical, you can provide your own validation function. For example:
errorMessage parameter it will be displayed in the invitation form when the user enters an email address that is already a member. Otherwise a default message will be displayed.