Okta Workflows Tutorial: Send a Rich Message to Microsoft Teams for a New Okta Event Using Microsoft API

This tutorial is part of Okta Workflows with Microsoft series:

  1. Send an Email Notification for a New Okta Event
  2. Send a Notification to Microsoft Teams for a New Okta Event
  3. Send a Rich Message to Microsoft Teams for a New Okta Event Using Microsoft API

This step-by-step tutorial will teach you how to send a rich message to Microsoft Teams.

This tutorial uses the flow you built in the Send Microsoft Teams Notification for a New Okta Event tutorial. 

Things you will learn:

  • How to send a rich message with Microsoft API.
  • How to use the Custom API Action card with Microsoft API.

The flow you built in the previous tutorial sends a text message to Microsoft Teams:

workflows_ms_teams_flow2.png (2678×1448)

The flow to send plain text messages to Microsoft Teams.

Send a rich message with Microsoft API

The flow you built in the Okta Workflows Tutorial: Send Microsoft Teams Notification for a New Okta Event uses the Send to Message to Channel pre-built action on the Microsoft Teams connector.

workflows_ms_teams_text_message.png (1490×1256)

Sending a text message to Microsoft Teams.

The Send Message to Channel action sends a text message but doesn’t support sending a rich or HTML message.

Looking at the Microsoft Teams API, it allows sending an HTML message. The screenshot below shows a request with an HTML message.

workflows ms teams2 microsoft api

Microsoft Graph API to send a message channel.

You need to set the content type to HTML to send a rich message. Since the contentType parameter is not exposed in the Send Message to Channel action, how do you make such all?

You can use the Custom API Action action on the connector to make this call.

The following section will teach you how to send an HTML message with Microsoft API in Okta Workflows.

Custom API Action

Most connectors have a Custom API Action action.

workflows_ms_teams2_customapiaction2.png (1286×1110)

Custom API Action.

Custom API Action action allows to call any API endpoint available in the connector.

The Custom API Action leverages an exiting connection authentication. You need to specify the relative endpoint URL and any request parameters required.

Learn more about Custom API Action: Four Ways to Call an API in Okta Workflows.

Update the send notification flow

To start, you will make a copy of the flow.

Duplicate the flow

You will make a copy of the flow you built in the Okta Workflows Tutorial: Send Microsoft Teams Notification for a New Okta Event tutorial.

  1. Duplicate the flow from the folders view.
    • In cards view, click duplicate on flow card.
    • In listing view, click ⚙️ > duplicate.
  2. Rename the flow to Send event notification to Microsoft Teams 2.

Add the Microsoft Teams Custom API Action

  1. Open the Send event notification to Microsoft Teams 2 flow.
  2. Click Add app action > Microsoft Teams connector > Custom API Action.
  3. Select POST for Request Type in Options. Click Save.
  4. On fields selection step, in Inputs:
    • Uncheck Query and Headers.
    • Check Body.
    • Click Save.

The Microsoft Teams – Custom API Action card:

workflows_ms_teams_capia1.png (534×1184)

The Microsoft Teams – Custom API Action card.

Since you have a Microsoft Teams connection, the card automatically selects the connection:

workflows_ms_teams_capia1_connection.png (528×386)

Microsoft Teams connection.

Set card inputs

In this step, you will set up the Custom API Action card inputs.

The relative URL has the following format:

/teams/{Team Id}/channels/{Channel Id}/messages
  1. Use the Team Id and Channel Id values from the Send Message to Channel card in the flow to create the following URL:
/teams/44e28d56-4b86-4cf0-82f6-ac1909cfc9ef/channels/19%3A5431db0d2cb3436c902a20fd805eb7ee%40thread.tacv2/messages
  1. Paste the above URL into the Relative URL field on the Custom API Action card.

workflows_ms_teams_capia_with_url.png (530×1338)

Custom API Action with relative URL set.

Test the Custom API Action card

To test the card, use the following message:

{
"body": {
   "contentType": "html",
   "content": "<b>Hello</b>, <i>Okta Workflows</i>."
}}
  1. To test the card, click ▶️.
  2. Delete the empty {} and paste the message above into the Body field.
  3. Check the message in Microsoft Teams.

workflows_ms_teams_capia_message_test2.png (1132×324)

Rich message in Microsoft Teams.

Delete the Send Message to Channel card

  1. To remove the Send Message to Channel card, press X in the card’s upper-right corner.

Create a rich message

In this section, you will create a rich message with data from the User Activated event and pass it to the Custom API Action card.

  1. Replace the text in the Compose card with the following text:
{
  "subject": "🚨 User Activated",
  "body": {
     "contentType": "html",
     "content": "<b></b> (<u></u>), <i></i>."
   }
}

The Compose card:

workflows_ms_teams_capia_compose_1b.png (946×758)

The Compose card with new message.

  1. Pass the fields from the Read User card to the new Compose card’s message:

workflows_ms_teams_capia_compose_3.png (1504×912)

Updated Microsoft Teams message.

The final flow:

workflows_ms_teams_capia_final_flow.png (2676×1266)

Flow to send a rich message to Microsoft Teams.

In the following step you will test the flow.

Test the flow

Turn off the Send event notification to Microsoft Teams flow you avoid both flows run when you activate a user.

  1. Save the flow.
  2. Check the flow is on.
  3. Go to Okta Admin console > Directory and select a user to activate.
    • To deactivate a user first:
      • Click on a user to deactivate.
      • Click More Actions > Deactivate.
      • Click Deactivate to confirm.
  4. Click the Activate and Activate again to confirm.

Flow execution when activating a user:

workflows_ms_teams_capia_history.png (2298×1270)

Flow history execution.

The message in Microsoft Teams:

workflows_ms_teams_capia_message_test3.png (1420×820)

Message in Microsoft Teams.

Things you will learned:

  • How to send a rich message with Microsoft API.
  • How to use the Custom API Action card with Microsoft API.

This tutorial is part of Okta Workflows with Microsoft series:

  1. Send an Email Notification for a New Okta Event
  2. Send a Notification to Microsoft Teams for a New Okta Event
  3. Send a Rich Message to Microsoft Teams for a New Okta Event Using Microsoft API

Okta Workflows resources

🍫 Get help from Workflows specialists during weekly community office hours.

📺 Learn from Workflows videos.

🛟 Get help from support: discuss a Workflows topic or ask a question.

🙋🏻‍♀️ Get help from the community: join the #okta-workflows channelon MacAdmins Slack.

 

Tags

Workflows