ROQ Platform provides an interface to send emails via SendGrid. To use it in your project you need to create an account and then integrate it via console.

Mail configuration in console

In the console you can create new mail types. Each mail type has a key which you will use when you send the mail via GraphQL mutation.


How it works

If you are building on top of ROQ One then all this logic is implemented and working out of the box and nothing needs to be done! You can still read this documentation in case you want to customize it or you are just curious how things are working.

Send mails via GraphQL API

The easiest way to send email is to use the sendMail() mutation of ROQ Platform with the parameters mentioned below. This mutation allows you to send email to a set of email addresses, users, or user-groups. You can use multiple parameters in parallel.

  • recipients: nonUsers - List of emails. As these recipients are unknown to the system, you need to set the locale and the first and last name.

  • recipients: userIds - List of user IDs.

  • recipients: userGroups - List IDs of user-groups. You also need to set an operator: "AND" means only users that are a member of all groups that will receive the email. "OR" means all users that are member of any group that will receive the email.

  • allusers - If set to "true" all active registered users that opted-in will receive the email.

  • entities - Optional list of entities that can be used to load data. For instance, if you want to inform other users about a new uploaded file, then here you can set the ID and file type.

  • mailType - Name of the mail-type that should be used.

  • directlyInjectedVariables - With this parameter, you can inject variables that can be used in the mail template, like this: {{token}}

mutation sendMail {
    params: {
      entities: [{ uuid: "0a3bbe3a-4ea8-4f81-9ded-56a903ab0619", type: "user" }]
      recipients: {
        nonUsers: [
            email: "your.name@gmail.com"
            locale: "en-US"
            firstName: "ab"
            lastName: "rehman"
        userIds: ["35f703df-7e22-4ec9-a806-56dbd6c4b131"]
        userGroups: {
          userGroupIds: ["d9730639-e616-4edb-83c5-517bace4020f","ab7fbc56-3275-43af-9468-90f05e7b65f0"]
          operator: AND
        allUsers: false
      mailType: "CONFIRM_MAIL"
      directlyInjectedVariables: "{\"token\":\"aaa4f6c5518becb5d2df4fe673775ff6c9abd746\"}"