In this blog post, we’ll describe a new API Builder-based API subscription approval workflow that leverages Microsoft Teams for approving the request as follows:
API Builder Project
The API Builder project exposes two API’s:
POST /api/amplifycentralwebhookhandler– the webhook url that Amplify will call when a subscription approval request is made. This API will send an approval form card to an MS Teams channel using an MS Teams Incoming Webhook Connector URL. It’s flow is shown below:
POST /api/approver– API that will be triggered when the approve/reject buttons are pressed in the MS Teams approval form. It will update the subscription request and post a card to MS Teams indicating that the subscription request has been processed.
Its flow is shown below:
These APIs are created in an API-First fashion with the OpenAPI Specification (OAS) documents created in Stoplight in the following two repos:
The APIs are secured with API Key authentication in a header with key
apikey. The API key value is set as an environment variable.
A complete list of environment variables for this project is shown below:
CLIENT_ID=<YOUR AMPLIFY SERVICE ACCOUNT CLIENT ID> CLIENT_SECRET=<YOUR AMPLIFY SERVICE ACCOUNT CLIENT SECRET> API_KEY=<AN API KEY THAT YOU SET> MS_TEAMS_WEBHOOK_URL=<MS TEAMS INCOMING WEBHOOK CONNECTOR URL> API_CENTRAL_URL=<YOUR AMPLIFY CENTRAL URL> BASEURL=<THE BASE URL OF YOUR API BUILDER API>
The API Builder project can be found on GitHub.
A Docker Container image can be found on Docker Hub.
In this Amplify Central Unified Catalog custom API subscription approval workflow example we saw how API Builder can respond to subscription requests, integrate with Microsoft Teams to present an approval form to the API Approver, and update the request based on the approvers action.
Need help with API Builder? Extend your skills with Axway University.