A Journey for API Management Implementation

Understand what type of workflows undergo API creation with an amazing illustration of a Callable Journey example. API Management creats an API for a workflow having Callable Journey as a trigger.

To understand the functioning of API Management, it is mandatory to have a Callable Journey executing in the Gupshup integration platform.


Use case

Create an API for a user(s) logging into the Gupshup integration platform.

  • Trigger: Callable Journey-New call
  • Condition: If Else
  • Actions: Databases by Gupshup integration platform-Search record, Callable Journey-Return response

📘

It is mandatory for a journey to have Callable Journey-New call as a trigger and Callable Journey-Return response as the last action step to create an API using API Management.


Prerequisites

Create a collection named Employee login details in Databases of the Gupshup integration platform. Enrich the collection with the employee records containing name, ID, and password:

1479

Figure 1: Employee login details collection in Databases


Configuring the Callable Journey trigger

  • Under the Event section, search for the Callable Journey app and click on it. Then select the trigger event, New call, from the Triggers list.
  • No authorization is required since this is an internal app of Gupshup integration platform.
  • In the Name field, specify the name of the journey. E.g., Callable-Login API.
  • Select Request type and Response type as application/json.
  • Specify the input in the JSON format in the Input field. The input must contain a sample key-value pair as per the columns defined in the Employee login details collection:
  • {
  • "Name":"",
  • "Login":"",
  • "Password":""
  • }
  • In the Output block, specify the sample response in the JSON format. The value defined here becomes the response and can be seen in the Return response action of Callable Journey. E.g.,
  • {
  • "Status":""
  • }
983

Figure 2: The New call trigger


Configuring the Databases by Gupshup integration platform action

  • Click on the Simple Action button and choose the Databases by Gupshup integration platformapp from the drop-down list.
  • Choose the Search record action from the Actions list.
  • No authorization is required as this is the internal app of Gupshup integration platform.
  • Select the Employee login details for the Collection ID input field.
  • Now, drag and drop the appropriate data pills from the Callable Journey | New call Trigger Data Output Tree in the Employee name, ID, and Password field, respectively:
1315

Figure 3: Configuring Databases by Gupshup integration platform-Search record action


Configuring the If Else condition

Now, let's use the If Else Condition to validate the user trying to log into Gupshup integration platformork. Under the Steps section, click the Add a new step button (+ icon) and, click the Business Logic option. Then select the If Else Condition:

829

Figure 4: The IF Else Condition

The If Else Condition block will appear with the pre-indented action bars as illustrated here:

1107

Figure 5: The If Else Condition

Configuring the If Condition block

Let us validate and return true as a response when a user logs in to Gupshup integration platform with a valid ID and password.
In the Left Value field, pass the alt text
data pill by clicking from the Databases by Gupshup integration platform | Search record step under Data Tree Output. Select the Is true condition from the drop-down menu in the Condition field. Once successfully done, your If Condition block will look like the following screenshot with a heading If recordFound is true:

1643

Figure 6: The If Condition block

Configuring Callable Journey action under If Condition

  • Click the Please choose an action bar. Choose the Callable Journey app from the drop-down menu in the App field.
  • Select the action, Return Response, from the drop-down menu in the Action field.
  • Select Success in the Response type drop-down menu field and type true in the Status field:
1070

Figure 7: Callable Journey under the If Condition block

Configuring Callable Journey under Else block

Now, let us validate and return false as a response when a user logs in to Gupshup integration platform with an invalid ID and password. Configure Callable Journey under the Else block to do so:

  • Click the Please choose an action bar. Choose the Callable Journey app from the drop-down menu in the App field.
  • Select the action, Return Response, from the drop-down menu in the Action field.
  • Select Success in the Response type drop-down menu field and type false in the Status field:
991

Figure 8: Callable Journey under the Else block

Once all the configuration is done, the journey must look like this:

1493

Figure 9: Callable-Login API

Save the changes of the journey and click the Save & Start button.
This journey only executes when the trigger listens to a new call initiated via API. Read the next document to understand how to create an API for this journey and call it to execute the journey.