Configure the Action Chain to Invoke the Integration

Now that your page is ready, let’s define how the integration will be invoked. In our case, the integration will be invoked when the GetWeatherInformation button is clicked in the application.

Create an Event to Invoke the Integration

First, let’s create the event to invoke the integration.

  1. On the main-start page, click the GetWeatherInformation button on the canvas.

  2. In the Button pane, click the Events tab.

  3. Click New Event, then Quick Start: ‘click’.

  4. On the main-start/ButtonClickAction page, from the General category in the Actions pane, drag the Call REST Endpoint action and drop it below the Start icon on the canvas.

    The callRestEndpoint1 object is added to the page.

    Description of action_chain_event_endpoint.png follows
    Description of the illustration action_chain_event_endpoint.png

  5. In the Call Rest Endpoint pane, click Select Endpoint.

  6. In the Select Endpoint dialog, select your integration as the endpoint. Expand Service Connections, then your service connection, then select /weather.

  7. Click Select.

    The service connection shows the input parameters from the getWeather integration.

    Description of action_chain_event_pane.png follows
    Description of the illustration action_chain_event_pane.png

  8. In the Call Rest Endpoint pane, click Not Mapped for either the q or weatherkey parameter.

    The Map Variables to Parameters dialog is displayed. The Source pane shows the variables you added to your page, and the Target pane shows the input parameters defined in the integration. You’ll now map the integration parameters to the corresponding page variables.

  9. From the Source pane, drag the location variable to the q parameter in the Target pane.

  10. In the Target pane, select the weatherkey variable. Then in the Expression for box at the bottom of the screen, enter the API application key as a constant within quotation marks.

  11. Click Save.

    Description of action_chain_event_mapper.png follows
    Description of the illustration action_chain_event_mapper.png

  12. The input parameters now appear mapped. Select json as the Request Type.

Map Response Data to Page Variables

Your integration will receive weather forecast from the weather API and pass on the information to the Visual Builder application. So, now map the response data from the weather API to your page variables.

  1. From the Actions pane, drag the Assign Variables action to the plus icon below the call REST endpoint on the action chain.

  2. In the Assign Variables pane, click Assign.

    Description of vb_assign_variables.png follows
    Description of the illustration vb_assign_variables.png

    The Map Variables To Parameters dialog is displayed. The Target pane displays the page variables defined in your Visual Builder application.

  3. In the Source pane, under Action Chain, under Results, expand callRestEndpoint1, then expand body.

    The Source pane now displays the parameters defined in your integration. You had defined these parameters in the sample payload of the trigger connection of your integration.

  4. From the Source pane, drag the humidity attribute and drop it onto the humidity parameter in the Target pane. A connecting line between the two parameters represents the mapping.

  5. Similarly, map all the variables as listed in the following table.

    Source Pane Variables Target Pane Variables

    humidity

    humidity

    localtime

    localTime

    precipMM

    precipitationMM

    temp_C

    tempC

    temp_F

    tempF

    WeatherDesc, value

    weatherDescription

    winddir16Point

    WindDirection

    windspeedKmph

    windSpeedKm

    windspeedMiles

    windSpeedMiles

    The parameters are now mapped.

    Description of vb_responsedata_pagevariables_map.png follows
    Description of the illustration vb_responsedata_pagevariables_map.png

  6. Click Save to save the mapping.

    In the Assign Variables pane, all the variables are now listed as Mapped.

    Description of mapped_variables.png follows
    Description of the illustration mapped_variables.png

    Your application is now ready to invoke the integration to retrieve weather information.