Site iconAxway Blog

Amplify Central Connected Gateway Custom API Subscription Flow – CRM Contact Exists Use Case

Amplify Central Connected Gateway Custom API Subscription Flow CRM Contact Use Cases

In prior posts, we were introduced to API subscriptions in the Amplify Central Unified Catalog and we learned about the basics of how Amplify Central supports custom API subscription approval flows. Finally, we put it all together in a very basic custom subscription approval flow using Axway’s Amplify Integration Builder to automatically approved all subscription requests.

Now let’s look at a more complex API Subscription Approval flow that integrates with your business process systems (e.g. CRM) and incorporates the following facets:

Again, we will use Axway’s Amplify Integration Builder for our custom subscription approval flow and we’ll use Salesforce Sales Cloud for our CRM!

This data flow is described in the diagram below:

Dataflow Diagram

Note that this flow does not leverage the webhooks we discussed in the prior posts. Instead, the Integration Builder flow runs on a cron job (i.e. scheduled trigger) and uses the Amplify Central subscriptions API to check for subscription requests. The discovery agent should be configured for manual subscription approvals as described in Part 1.

As a reminder of an API Subscription process recall that we have an API consumer who discovers an API in the Axway Unified Catalog and in order to use it, subscribes to the API in order to get credentials (e.g. API Key). This is described in the screenshots below:

Unified Catalog APIs
Selected API
Subscribe to API
Subscription Waiting for Approval

When the subscription is approved, the user can get an email with credentials as shown below:

Autogenerated Credentials Email

You can view the end-to-end process here.

Amplify Central/Discovery Agent Setup

As described above, the Amplify Central discovery agent should be set up for manual approval and sending the email to the subscriber as described in the discovery_agent.yml fragment below:

.
.
.
subscriptions:
  approval:
    mode: manual

  notifications:
    smtp:
      host: email-smtp.us-east-1.amazonaws.com
      port: 587
      username: xxxxxxxxxxxxxx
      password: yyyyyyyyyyyyyy
      authtype: PLAIN
      fromAddress: noreply-demo@axway.com
      subscribe:
        subject: Subscription Notification
        body: |
           Subscription created for Catalog Item:  <a href= ${catalogItemUrl}> ${catalogItemName} </a> <br/>
           ${authtemplate}<br/>
        oauth: Your API is secured using OAuth token. You can obtain your token using grant_type=client_credentials with the following client_id=<b>${clientID}</b> and client_secret=<b>${clientSecret}</b>
        apikeys: Your API is secured using an APIKey credential:header:<b>${keyHeaderName}</b>/value:<b>${key}</b>
      unsubscribe:
        subject: Subscription Removal Notification
        body: |
           Subscription for Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a> has been unsubscribed
      subscribeFailed:
        subject: Subscription Failed Notification
        body: |
             Could not subscribe to Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a>
      unsubscribeFailed:
        subject: Subscription Removal Failed Notification
        body: |
           Could not unsubscribe to Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a>
.
.
.

the discovery_agent.env fragment below:

.
.
.
CENTRAL_SUBSCRIPTIONS_APPROVAL_MODE=manual
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_HOST=email-smtp.us-east-1.amazonaws.com
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_PORT=587
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_USERNAME=xxxxxxx
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_PASSWORD=yyyyyyyy
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_AUTHTYPE=PLAIN
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_FROMADDRESS=noreply-demo@axway.com
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBE_SUBJECT=Subscription Notification
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBE_BODY=Subscription created for Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a> <br/>Your API is secured using an APIKey credential: header:<b>${keyHeaderName}</b> / value:<b>${key}</b><br/>${authtemplate}<br/>
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBE_OAUTH=Your API is secured using OAuth token. You can obtain your token using grant_type=client_credentials with the following client_id=<b>${clientID}</b> and client_secret=<b>${clientSecret}</b>
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBE_APIKEYS=Your API is secured using an APIKey credential:header:<b>${keyHeaderName}</b>/value:<b>${key}</b>
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_UNSUBSCRIBE_SUBJECT=Subscription Removal Notification
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_UNSUBSCRIBE_BODY=Subscription for Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a> has been unsubscribed
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBEFAILED_SUBJECT=Subscription Failed Notification
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_SUBSCRIBEFAILED_BODY=Could not subscribe to Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a>
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_UNSUBSCRIBEFAILED_SUBJECT=Subscription Removal Failed Notification
CENTRAL_SUBSCRIPTIONS_NOTIFICATIONS_SMTP_UNSUBSCRIBEFAILED_BODY=Could not unsubscribe to Catalog Item: <a href= ${catalogItemUrl}> ${catalogItemName} </a>
.
.
.

Integration Builder Flow

The Integration Builder flow is shown below:

Integration Builder Flow

Before we go into the flow description, let’s look at the Flow Instance below:

Flow Instance

The variables are:

Retrieve clientId and clientSecret

If you don’t already have a service account and clientId and clientSecret, follow the instructions below.

We will make the following CLI commands in order to:

Note that you will need jq installed on your environment for the authentication curl command shown below

Enter your Organization ID (e.g. 100000142) and the serviceAccountName (e.g. catalog-integration) in the CLI command below and execute the following two commands manually. This is a one-time activity to create a service account and retrieve the clientId and clientSecret.

axway auth logout --all

axway auth login

ORG_ID=100000142 && TOKEN=$(axway auth list --json | jq -r ".[] | select( .org.id == $ORG_ID ) | .auth.tokens.access_token") && curl -vv 'https://apicentral.axway.com/api/v1/serviceAccounts' --header "Authorization: Bearer ${TOKEN}" --header "X-Axway-Tenant-Id: ${ORG_ID}" --header 'Content-Type: application/json' --data-raw '{
  "serviceAccountType": "DOSA",
  "serviceAccountName": "catalog-integration",
  "clientAuthType": "SECRET"
}'

Flow Description

SFDC Contact
SFDC Contact Notes
SFDC Contact Note Details
MS Teams Message

You can download the flow here.

Summary

In this API Subscription Flow example, we saw how Integration Builder, with its CRM connectors, enables a robust subscription flow that integrates with your CRM-based business processes for customers and prospects and also enables you to handle employee and partner subscription requests.

Read more about Amplify Central Connected Gateway Custom API Subscription Flow — Integration Basics.

Exit mobile version