-
Notifications
You must be signed in to change notification settings - Fork 9
Configure Microsoft Flow for receiving AMPLIFY Unified Catalog Subscription events
AMPLIFY Unified Catalog has the option to configure Webhooks that can be invoked when Consumers of Catalog asset update their subscriptions. An example on how to set up a Webhook using REST APIs is available in this Postman Collection.
This wiki page describes how you can configure a Microsoft Teams flow to receive subscription notifications from the Unified Catalog, and Approve / Reject subscription requests using Adaptive Cards.
Pre-requisite:
- You'll need Microsoft Flow to create the flow, with a Free Trial account at a minimum to be able to create the flow.
- Navigate to Microsoft Flow.
- Create the Webhook entry point that Unified Catalog will send the events to.
- Go to "My flows".
- Create an
Instant flow
, provide aname
and selectWhen an HTTP request is received
as an entry point. - In the request json body schema, copy and paste the Subscription Updated Event schema below:
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"time": {
"type": "string"
},
"version": {
"type": "string"
},
"product": {
"type": "string"
},
"correlationId": {
"type": "string"
},
"organization": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"type": {
"type": "string"
},
"payload": {
"type": "object",
"properties": {
"consumerInstance": {
"type": "object",
"properties": {
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"group": {
"type": "string"
},
"metadata": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"audit": {
"type": "object",
"properties": {
"createUserId": {
"type": "string"
},
"modifyUserId": {
"type": "string"
},
"createTimestamp": {
"type": "string"
},
"modifyTimestamp": {
"type": "string"
}
}
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"references": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"id",
"kind",
"name",
"type"
]
}
},
"resourceVersion": {
"type": "string"
}
}
},
"apiVersion": {
"type": "string"
},
"attributes": {
"type": "object",
"properties": {
"release": {
"type": "string"
}
}
}
}
},
"subscription": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"userId": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"metadata": {
"type": "object",
"properties": {
"createUserId": {
"type": "string"
}
}
},
"currentState": {
"type": "string"
},
"owningTeamId": {
"type": "string"
},
"relationships": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"path": {
"type": "string"
},
"spec": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"path",
"spec",
"type",
"value"
]
}
},
"nextPossibleStates": {
"type": "array"
},
"currentStateDescription": {
"type": "string"
}
}
},
"catalogItem": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"owningTeamId": {
"type": "string"
},
"relationships": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"path": {
"type": "string"
},
"spec": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"path",
"spec",
"type",
"value"
]
}
}
}
}
}
}
}
}
- Add an extra step of type
Control
, action typeCondition
.- Set the the value for the
Condition
, by searchingcurrentState
using theAdd dynamic content
. - Set the operator to
is equal to
and value set toREQUESTED
.
- Set the the value for the
- Set up the Adaptive card. The subscription requests will be Approved or Rejected based on the response of the action in the Adaptive Card.
- On the
If yes
branch, selectAdd a new action
of typePost an Adaptive Card to a Teams channel and wait for the response
. - Configure the
Team
and theChannel
where the card would be posted. - Copy-paste the text below in
Message
box:
- On the
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Subscription requested",
"weight": "Bolder",
"size": "Medium"
},
{
"type":"Image",
"url":"https://upload.wikimedia.org/wikipedia/commons/5/5a/Axway_Logo.png",
"spacing": "Small",
"horizontalAlignment": "Center",
"height": "stretch",
"size": "Medium"
}
]
},
{
"type": "Container",
"style": "accent",
"items": [
{
"type": "FactSet",
"facts": [
{
"title": "Catalog Item",
"value": "@{triggerBody()?['payload']?['catalogItem']?['name']}"
},
{
"title": "Subscription",
"value": "@{triggerBody()?['payload']?['subscription']?['name']}"
},
{
"title": "Message",
"value": "@{triggerBody()?['payload']?['subscription']?['currentStateDescription']}"
},
{
"title":"Requested plan",
"value": "@{triggerBody()?['payload']?['subscription']?['properties']?['profile']?['plan']}"
}
]
}
]
},
{
"type": "TextBlock",
"text": "Select your action:",
"weight": "Bolder",
"wrap": true
},
{
"type": "Input.ChoiceSet",
"placeholder": "Enter your action",
"id": "action",
"choices": [
{
"title": "Approve",
"value": "approved"
},
{
"title": "Reject",
"value": "rejected"
}
],
"style": "expanded"
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Submit",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "comment",
"isMultiline": true,
"placeholder": "Enter your comment"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "Team details",
"url": "https://apicentral.axway.com/access/teams/detail/@{triggerBody()?['payload']?['subscription']?['owningTeamId']}"
},
{
"type": "Action.OpenUrl",
"title": "User details",
"url": "https://platform.axway.com/#/user/@{triggerBody()?['payload']?['subscription']?['metadata']?['createUserId']}"
},
{
"type": "Action.OpenUrl",
"title": "View Subscription in Unified Catalog",
"url": "https://apicentral.axway.com/catalog/@{triggerBody()?['payload']?['catalogItem']?['id']}/subscriptions/@{triggerBody()?['payload']?['subscription']?['id']}"
}
],
"minHeight": "100px"
}
- Set the
Update Message
to:
Subscription "@{triggerBody()?['payload']?['subscription']?['name']}" processed for "@{triggerBody()?['payload']?['catalogItem']?['name']}"
- Set the
Should update card
toyes
.
-
Add an action of type
HTTP
to configure calling to Integration Builder- Set
Method
toPOST
- Set
URI
tohttps://staging.cloud-elements.com/elements/api-v2/formulas/instances/{FORMULA_INSTANCE_ID_HERE}/executions
- Set
Headers
toContent-Type: application/json
- Set the
Body
to
{ "catalogItem": { "id": "@{triggerBody()?['payload']?['catalogItem']?['id']}", "name": "@{triggerBody()?['payload']?['catalogItem']?['name']}", "relationships": @{triggerBody()?['payload']?['catalogItem']?['relationships']} }, "subscription": { "id": "@{triggerBody()?['payload']?['subscription']?['id']}", "action": "@{body('Post_an_Adaptive_Card_to_a_Teams_channel_and_wait_for_a_response')?['data']?['action']}", "message": "@{body('Post_an_Adaptive_Card_to_a_Teams_channel_and_wait_for_a_response')?['data']?['comment']}", "userId": "@{triggerBody()?['payload']?['subscription']?['metadata']?['createUserId']}", "relationships": @{triggerBody()?['payload']?['subscription']?['relationships']}, "properties": @{triggerBody()?['payload']?['subscription']?['properties']} } }
- Click on
Show advanced options
and setAuthorization
toRaw
, value being your Integration Builder User and Org secrets:User ****, Organization ****
- Set
-
Add a new Microsoft Teams action as
Post a message as the Flow bot to a channel
.- Select the
Team
and theChannel
- Set the
Message
field to:
Subscription "@{triggerBody()?['payload']?['subscription']?['name']}" on "@{triggerBody()?['payload']?['catalogItem']?['name']}" was sent to be @{body('Post_an_Adaptive_Card_to_a_Teams_channel_and_wait_for_a_response')?['data']?['action']} by "@{body('Post_an_Adaptive_Card_to_a_Teams_channel_and_wait_for_a_response')?['responder']?['displayName']}" (@{body('Post_an_Adaptive_Card_to_a_Teams_channel_and_wait_for_a_response')?['responder']?['email']})
- Select the
-
Set up the
If no
branch. The flow will always post a message to a teams channel when a subscription state changes and the current state is different thanREQUESTED
.- Select
Post a message as the Flow bot to a channel
action. - Pick the
Team
andChannel
- Set the
Message
field to:
Subscription "@{triggerBody()?['payload']?['subscription']?['name']}" for "@{triggerBody()?['payload']?['catalogItem']?['name']}" state changed to @{triggerBody()?['payload']?['subscription']?['currentState']}
- Select
-
Add a
Control
,Condition
action.- Set the the value for the
Condition
tocurrentState
- Set the operator to
is equal to
and value set toUNSUBSCRIBE_INITIATED
.
- Set the the value for the
-
On the
If yes
branch, send the event data to Integration Builder.- Select a
HTTP
action. - Set the
Method
toPOST
- Set the
URI
tohttps://staging.cloud-elements.com/elements/api-v2/formulas/instances/{FORMULA_INSTANCE_ID_HERE}/executions
- Set the
Headers
toContent-Type: application/json
- Set the
Body
to:
{ "catalogItem": { "id": "@{triggerBody()?['payload']?['catalogItem']?['id']}", "name": "@{triggerBody()?['payload']?['catalogItem']?['name']}", "relationships": @{triggerBody()?['payload']?['catalogItem']?['relationships']} }, "subscription": { "id": "@{triggerBody()?['payload']?['subscription']?['id']}", "action": "unsubscribeInitiated", "userId": "@{triggerBody()?['payload']?['subscription']?['metadata']?['createUserId']}", "relationships": @{triggerBody()?['payload']?['subscription']?['relationships']} } }
- Click on
Show advanced options
and setAuthorization
toRaw
, value being your Integration Builder User and Org secrets:User ****, Organization ****
- Select a
- Save the flow