Reading Time: 9 minutes

In this blog post, we will talk about “Flow Designer,” the online component which has a wide set of features for the creation of basic integrations and to “enable” backend components by making them ready for API-led connectivity.

Flow Designer runs on the control plane and is available with the basic subscription as well as with the trial account. It enables the Citizen Integrator to create Mule applications that are deployable directly to CloudHub. They can also be exported as a Mule project for further enrichment using Anypoint Studio as well as published in Exchange to form the basis for a template project.

latest report
Learn why we are the Leaders in API management and iPaaS

Learn more about using Flow Designer you should consider taking the Anypoint Platform: Flow Design instructor-led training course. 

Example use case

The use case is that of a customer who is running a spaceport to launch vehicles into outer space. They need to know, among the huge variety of other details, the current temperature at the time of launch in order to set the appropriate temperature of the cooling fluid that cools down the engine to prevent under- or overheating.

One of the APIs that needs to be called is the RESTful web service of the “AccuWeather” resource to calculate temperature value on the Kelvin scale. Based on this data, the customer will need to deploy a process API to calculate the spaceship’s launch parameters.

We will use Flow Designer to connect to the “AccuWeather” API by using the HTTP connector and performing temperature transformation to Kelvin. After that, we will create a template and publish it to Anypoint Exchange to enable reuse by “experience layer” developers. If you want to try this for yourself please review AccuWeather’s API documentation for the current conditions endpoint and request an API key which you must set as a query parameter on the request. 

Designing a flow

Our project in Flow Designer will have three cards that will listen for an incoming HTTP request, make and outgoing HTTP request and transform the data received:

The first card is the flow trigger. This is an HTTP listener that fires when an HTTP request is made to the /temperature endpoint.

Fig 1: A request to the endpoint /temperature triggers the HTTP listener.

Once triggered, a request will be sent to the AccuWeather’s API current condition resource. 

Fig 2. Request to the AccuWeather resource. 
 Fig 3. HTTP Request configuration connection.

Note: Remember to set the apikey query parameter.

The response includes the current temperature for the location specified as a URI parameter, and will resemble the following JSON snippet:

{ "Temperature": 
{"Metric": { 
"Value":6.9, 
"Unit": "C", 
"UnitType": 17 }, 
"Imperial": {
"Value": 44.0, 
"Unit": "F", 
"UnitType": 18 }
}

The transform component will retrieve the temperature value from the response and transform it to Kelvin using the DataWeave script: temperatureKelvin: payload.Temperature.Metric.Value[0] + 273.

Fig 4. Transformer card.

The result of this API call will be: {“temperatureKelvin”: 281.7} (This number depends on the current temperature)

The completed flow will contain the above three cards.

 Fig 5. Template design in Flow Designer.

Deploy and publish the flow

There are two further options that can be performed with our new System API:

  1. We can deploy an API to CloudHub and start using it immediately to perform temperature conversion to Kelvin.
  2. It can be published to Exchange as a template for the further development

Publish the flow to Exchange

Now, let’s publish it to Exchange.

  1. Select the “Publish template” button from the top-right drop-down menu.
  1. Enter an appropriate name for the template and publish it to Anypoint Exchange. All sensitive information will be removed, except for the API key query parameter. It might be wise to remove it prior to publishing.
  1. View the published template in Exchange.

As a next step, developers can pick up this template and import it into Anypoint Studio and add extra functionality to it if needed. 

Create a Mule project from a template

Create a new Studio project by importing the SAPI_getKelvinTemperature  template from Anypoint Exchange.

Fig 6. Creating a new project from a template.

Once a new Studio project has been created based on this template, you can enhance it with extra functionality. To learn more about template-driven development see this blog post: Template-driven development with Flow Designer.

Summary

As is shown above the new functionality of Anypoint Flow Designer allows you to publish your projects as a template to your organisation’s Anypoint Exchange. It gives MuleSoft Developers the opportunity to start development from a template design — thereby facilitating the creation of Mule projects and reducing the software development lifecycle.

The Citizen Integrator can create simplified projects configured with desired connectors and a simple transformation without deep knowledge of Anypoint Studio.

MuleSoft provides various training courses which are covering different API lifecycle components with help of which you can achieve implementation of application network faster with a better business outcome.