API Builder

Amplify Central custom API subscription approval flow – CRM contact check flow using API Builder

In a previous blog post, we described how to use Integration Builder to create an Amplify Central custom API Subscription approval flow that checks to see if the subscriber exists in Salesforce, based on the subscriber’s email address. If so, we approve the request. If not, we send a notification to Teams as follows:

MS Teams Notification Example

Then the approval team can add the user to Salesforce which will cause the request to be approved or they can manually reject the request in Central.

An additional feature in the flow is that if the subscriber’s email is in a whitelist that you define, then the subscription is automatically approved. This is useful for allowing employees and partners to be automatically approved.

Now, we’ll do the same flow but we’ll use API Builder. This will give you more flexibility in choosing which Amplify product suits your needs better.

API Builder project

There are two flows in the project:

  • Approval Flow – Main flow that runs on a timer (using the timer plugin) and retrieves a list of Subscription that are in the REQUEST state. It also retrieves a Salesforce token for API requests that are made in the next flow. Finally, it invokes the Subscriptions Checker in a loop over the list of Subscriptions. Note that you can use the cron plugin if you’d like to specify a cron expression for triggering your flow.
API Builder Main Approval Flow
  • Subscriptions Checker – Flow that is invoked from the main flow in a loop over the list of subscriptions. It checks to see if the subscriber is in a whitelist or is a contact in Salesforce.
    • If the subscriber is part of the white list, then the subscription is approved
    • If the subscriber is in Salesforce, then the subscription is approved and a note is added to the contact
    • If neither, then a notification is sent to MS Teams to alert the approval team. If the approval team adds the subscriber to Salesforce. Then on the next iteration of the main flow, the subscription will be approved and the agents will complete the approval process.
API Builder Subscriptions Checker Flow

Here are the major aspects of the flows:

  • The API Builder swagger flow node and the Amplify Unified Catalog API swagger are used to create a connector to Amplify Central/Unified Catalog for checking for pending subscriptions
  • I am using the API Builder REST flow node to make a Platform API call to retrieve the subscriber user details (name and email). I am using the access_token retrieved for the Unified Catalog API for my Platform API call
  • I am using Salesforce REST APIs and the API Builder REST flow node to integrate with Salesforce

The following Environment variables are used in the project:

  • API_CENTRAL_URL – Base address for Amplify Central (e.g. https://apicentral.axway.com)
  • CLIENT_ID – Amplify Service account client id
  • CLIENT_SECRET – Amplify Service account client secret
  • SFDC_DOMAIN_NAME – Your Salesforce Sales Cloud domain name (for REST API calls). For example, d37000000i55oeac-dev-ed for my Salesforce instance at https://d37000000i55oeac-dev-ed.my.salesforce.com/
  • SFDC_CLIENT_ID – Your Salesforce connected app consumer key
  • SFDC_CLIENT_SECRET – Your Salesforce connected app consumer secret
  • SFDC_USERNAME – Your Salesforce username
  • SFDC_PASSWORD – Your Salesforce password
  • SFDC_SECRET – Your Salesforce secret
  • WHITELIST – an array of email domains that you want to allow to be auto subscribed (e.g. [axway.com, appcelerator.com])
  • MS_TEAMS_WEBHOOK_URL – URL of the MS Teams incoming webhook connector for the channel that the notifications should be sent to
  • INTERVAL – timer interval in mS for how often you want to check Amplify for pending subscription requests

You can read about creating an Amplify Service Account and retrieving your client id and secret here.

You can read about Salesforce REST APIs and how to create a connected app here. In addition, you need to modify two OAuth Policies from their default state: Permitted Users and IP Relaxation.

  • In the Administer section click on Manage Apps -> Connected Apps and Edit the Connected App you created and make the following modifications in the OAuth Policies section:
    • Change Permitted Users to All users may self-authorize
    • Change IP Relaxation to Relax IP restrictions

To use this API Builder project simply setup your Salesforce connected account and Amplify service account and collect all the environment variables and run the API Builder project. It will check the requested API subscriptions based on the timer interval. Set the timer properly to avoid spamming MS Teams with the same subscription notifications. For example, add the environment variables to the /conf/.env file and run the project using npm start

The API Builder project can be downloaded here.


In this Amplify Central custom API Subscription Flow example we saw how API Builder enables a robust subscription flow that integrates with your CRM based business processes for customers and prospects and also enables you to automatically approve employee and partner subscription requests via a whitelist.

Need help with API Builder? Extend your skills with Axway University.