How to use operations in your flow to enrich your flow or send data to an external API
With the "Operation" step in Qonfi, you can retrieve data from your product feed or from an external API in between the steps in your flow. You can save this data as a variable in your flow and use it to enrich your flow.
Example 1: Retrieve data from an external API
Whenever you have a flow where you do anything with vehicles, it's often useful to have the user's vehicle information available in your flow. In this example we'll show you how you can use an Operation step to retrieve the user's vehicle information from an external API using the license plate number entered by the user.
1. Add the license plate number input
Add a text input for the license plate number.
2. Save the entered license plate number to a variable
Open the answer and add a variable "license_plate_number" and check "Use input" to save the entered input to the variable.
3. Configure the API request
Add an "Operation" step (you can find this under "Advanced" in the sidebar) and select an "Add API operation" from the dropdown.
Open the API operation and configure the API request. In our case we'll use the RDW open data API to get vehicle information based on a dutch license plate.
As you can see, we're using the previously set "license_plate_number" variable as a query parameter in the request url to make sure we get the vehicle based on the entered license plate number by the user.
The "Variable name" determines how the retrieved data will be saved. You can give this any name you want. In our case we've named this vehicle_information. This way we can retrieve this data later by using the {vars.vehicle_information.field} format.
4. Using the API request data in your flow
When we do the API request, we get a response that looks like this:
For demonstration purposes, we'll just add another step in our flow just to display some of the retrieved vehicle information.
Since the API returns an array of vehicles, we can use [0] to retrieve the first returned vehicle.
5. Result
This will result in the following flow:
When we test this flow, we'll get the following result:
Example 2: Send data to an external API
Just like you would configure the API request in the previous example to retrieve data, you can also configure the API request to send collected data to an external API.
In the previous example, we showed you how you can get vehicle information based on a license plate number entered by the user. Let's say you also want to send that license plate number to your own API to store it for the currently active user.
To do this, simply go back to the operation we've added in the previous example and add an additional API operation.
As you can see, we're sending the entered license plate to your own API.
For demonstration purposes, we've also configured a request header "Authorization" with a "bearer_token". In Qonfi, you can store existing data from your website as a variable in Qonfi and use it in your flow. In this example we've stored a "bearer_token" variable to identify our user and make sure the license plate number is saved to the correct user in using the API.
Example 3: Retrieve data from your feed
In some cases, you might want to get some data from your feed and use it in your flow. This is mostly used when you need to show prices for specific products that you are upselling when configuring product bundles.
In our "Garden tiles product bundle demo" we let users configure a product bundle that exists of tiles, beams and (optionally) sand. In the last step we ask the user if they need sweeping sand. In this case the additional cost of the sand is based on the actual price of the sand and a specific calculation.
1. Add the feed operation
First we add an "Operation" step and add a "Feed operation" to get the actual price of the sand from the feed. We have added product match rules to select the first product from our product feed that has the "sand" category. We'll save the result of the feed as the "sand_product" variable so we can use this later in the flow.
2. Use the feed operation result in our flow
The variable configured in the feed operation will now contain the product from the feed with all the feed properties. We can use these properties in our flow like for example: {vars.sand_product.sale_price}. In our example we also need to do some calculations, so we'll end up with:
Good to know: You can also use your API data in your product advice or populate your questions with dynamic answers using your API data.
Documentation