Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To do this, from the app's overview page, go to : API Permissions

...

> Add a Permission

...

> Microsoft Graph

...

> Application Permissions

...

. Use the search bar to search for "Mail", Select Mail list and tick "Mail.Send"

...

and you can tick  "User.Read

...

"

...

if you want to see the list of users who can use this Azure app

...

And now . Add the permissions to grant your Azure app has the permission to send emails!


Image Added


Figure 6: API Permission Settings  

Using Joget JSON Tool to Call API

The Joget JSON Tool is a plugin for app processes included in the Process builder that lets you issue JSON web service calls. In order to properly send an email with the MS Graph API, you will need in total 2 of these JSON tools. One to request for an access token and the other to actually send the email.

...

Courtesy to Microsoft's documentation, to acquire the access token, you will need a POST request to the urlURL:

https://login.microsoftonline.com/[TENANT ID HERE]/oauth2/v2.0/token

So, enter the appropriate information into your first JSON Tool and keep the Body Type as "Request Parameters".

Image Modified

Figure 7: Token Request Call

Info

Make sure to insert your own tenant ID

Next up is to give the request the appropriate parameters, this request will need 4 thingshas to include the following:

  • A client ID
  • The client secret
  • A grant type
  • And a scope

...

Other authentications flow would let you be more specific with your scope, like entering "Mail.send" but for client credentials it must have a value with the "/.default" suffixed to the application ID URI, which by default is "https://graph.microsoft.com/". Enter the link to the value with the name "scope".

Image Modified

Figure 8: Request Parameters 

The result of this request takes form of a JSON object, if your request was successful, the JSON object should look something like this:

...

The "access_token" property of this JSON object is what we need for our second JSON tool, and for this guide, we will store this value in a workflow variable. You can create a workflow variable by going to the "Process Property", which in Joget DX8, is accessible via the pencil icon beside your process' name.

Image Modified

Figure 9: Process Properties 

Add as many variables as you need and name them appropriately.

Back at your JSON tool, scroll down to the "Store to Workflow Variable" setting and enter the variable of your choice and give the JSON object name "access_token".

Figure 10: Store to Workflow Variable Setting 

Upon Completion, you would And with that, we have successfully requested and stored our access token for the second JSON tool.

...

For this guide, we will be using the first one, enter the appropriate information to your second JSON tool and make the Body Type as "Custom JSON Payload".

Figure 11: Mapping Configurations  

Getting userPrincipalName via Azure

...

From the Home screen go to : Azure Active Directory

...

And in that screen you > Users. You can see a list of all the valid users, it should be filled with around a dozen dummy accounts and your account. Copy paste your or any of the "User Principal Name" in that list to your request link and this time the request will be valid.

...

From the same menu, you can get userPrincipalName and ID via GET Request (Optional).

Optionally, you can extract both the "User Principal Name" and their ID, by doing a GET request to the link,

...

"Content-type" is used so the request knows what type of payload is it using, which for our case is a JSON object, so enter the value "application/json".

Image Modified

Figure 12: Request Header I   

"Authorization" as the name suggests is used to authorize the request, this is where you will use your access token, the value for this request header will be a string in the format "[TOKEN_TYPE] [TOKEN]", the type of token we are using will be a "Bearer" token and you can simply copy paste the token or use a hash variable to extract the token that was stored in the workflow variable.

Image Modified

Figure 13: Request Header II 

Conclusion

And that's it! With a minimum of 2 JSON Tools, you will be able to send an email using the MS Graph API. By the end, the process of your application should look something like the picture below, 2 tools for requesting an access token and sending the email and any additional activity for automating some of the process, like for the demo app, it is for automating creating the message.

Image Modified

Figure 14: Process Builder of Send Email using MS Graph Demo App

Demo App

Here is the demo app that showcases this guide, please do keep in mind all of the information related to the Azure app has been left empty since those should be filled with your own Azure app. Most of these empty information can be find in the process of the application.

...