Introduction

Nearly every web application gets better and better as more users are registered and regularly use the service. For this reason, ROQ Platform allows users to easily invite new users.

How it works

If you are building on top of ROQ One, this logic is implemented and working out of the box, meaning you don’t need to do anything! However, you can still read this documentation if you wish to customize it or you are just curious about how things work.

Preparation: mail configuration

User invites are always sent via e-mail. For this reason a mail-type needs to be configured with this key: USER_INVITE_MAIL

Invite a user

The sendUserInvites() mutation lets you send invites to a number of users at once. The invite is valid for 24 hours and can be extended using the refreshUserInvite() mutation.

You can use the sendUserInvites() mutation with these parameters:

  • email - Email of the invited person

  • firstName

  • lastName

  • createdByUserId - ID of the user who invited

  • locale - Locale to be used

  • data - JSON field that can be used to add any custom data to the invite (e.g. the user-group that should be used)

mutation sendUserInvites($userInvites:[UserInviteCreateDto!]!){
  sendUserInvites(userInvites:$userInvites){
    success{
      id,
      firstName
      lastName
      status
      statusUpdatedAt
    },
    errors{
      firstName
      lastName
      email
      error
    }
  }
}
GRAPHQL

Response:

  • success - Array showing all the invites which were sent successfully

  • errors - Array with invites which were not sent with the reason why they were failed

To send an invite again to the same user you can use the resendUserInvite() mutation. In case you want to cancel an invitation then please use the cancelUserInvite() mutation. You can check the validity of an invite using the checkUserInviteToken() mutation.

Accept an invite

When a user accepts an invite then you should use the acceptUserInvite() mutation to set the status accordingly. You need to submit the received token as a parameter:

  • token - token of the invite

mutation AcceptUserInvite($acceptUserInvite:AcceptUserInviteDto!){
  acceptUserInvite(acceptUserInvite: $acceptUserInvite){
    id
    firstName
    lastName
    status
    statusUpdatedAt
    data
  }
}
GRAPHQL