Solved

Systemflow to send e-mail notifications

  • 8 March 2023
  • 4 replies
  • 255 views

Userlevel 5
Badge +20

We would like to set up a system flow for sending notifications by email. Preferably use Office 365 as mail server.

What are the best practices for this scenario?

Via SMTP or using the Graph API?

Is there an example available of a scheduled system flow that sends email notifications, via Office365 with the Oauth connector?

icon

Best answer by Arie V 17 March 2023, 10:06

View original

This topic has been closed for comments

4 replies

Userlevel 7
Badge +23

Hi Harm,

Depending on what exact notifications you would like to e-mail to your users, you can create a System flow that checks a set of data, and based on certain conditions then sends an email using the SMTP connector. Using the Graph API is also possible but it may be more time-consuming to create this integration.

In this topic I have previously shared a possible System flow that incorporates e-mailing:

In 2023.2, we will provide a E-mail connector which will allow you to use different E-mail providers such as Microsoft Graph and Sendgrid. 

I'm not aware of if we have any example that uses the Graph API with the OAuth connector.

Userlevel 5
Badge +20

If you are not aware, how can we ever find an example?

We know how to make a process flow with an SMTP connector, but O365 requires Oauth authentication, which makes it a bit more challenging.

Please provide us complete information, for both options (SMTP, Graph) including an easy to understand step-by-step explanation on how to set up this. 

Somewhat complex functionality like this, without a proper help function or documentation is useless.

 

 

 

 

Userlevel 7
Badge +23

Information here can be handy:

With a OAuth server (SF > Model overview > Branch), you can input both an Authorization URL and a Token URL. Using the following webpage, both URLs can be createdhttps://learn.microsoft.com/en-us/graph/auth-v2-user

This OAuth server you can then use inside the OAuth user login and OAuth refresh token process action. This should result in an Access token with you can use in the Bearer input parameter of the HTTP connector. That will solve the authentication.

The URL is the endpoint of the Graph API you would like to call. Using the correct HTTP method, Content type and Content based on what the Graph API expects, should ensure that the email is sent for example.

I personally haven't worked with the Graph API, hence my awareness. Maybe @Roel can elaborate on this, he has recently worked with the API.

Userlevel 6
Badge +10

@Harm Horstman Come on, you're smart enough to get this working! 😉 We have more or less what you describe, except we send notifications to Teams instead of Email through the Graph API. 

Step 1: perform the steps as described in the Microsoft URL provided by Mark: https://learn.microsoft.com/en-us/graph/auth-v2-user

Step 2: perform the steps as described in the Blog from Dick as referred to by Mark: 

  • Also read the Comments from me below that Blog
  • Also see my Comments here:
  • Also see my below recommendations

Some suggestions from our side

Split up the process in 3 distinct Process Flows:

  1. Process Flow with Task: OAuth Login connector + Decision node to write the Authentication and Refresh token to your Application → a Process Flow that you would start with a Task to trigger the Login. Basically only needed once, or once the below Scheduled Refresh flow fails (could happen after too long downtime of your Application).
  2. Scheduled System Flow: OAuth Refresh connector flow to update the Access and Refresh token before it expires (we do this every 29 minutes). This ensures you always have a valid Access token available for the next Process Flow.
  3. Scheduled System Flow: Basically the 3rd part is a regular HTTP Connector flow, in which the above retrieved Access token is used.

Be aware that Indicium / Universal GUI do not work well with the OAuth Login connector in all environments, even though it is supposed to be supported since Universal GUI 2023.1.12. If you encounter issues with the first Process Flow, you could also perform that step with Insomnia or Postman and update the response manually in your application.

We use a dedicated ‘automation@<yourdomain> user to send the notifications with the appropriate rights in the Azure AD App.

 

Let me know if you have more specific follow up questions!