Following are the steps to setup External APIs in Custom Bots :
- Select the option ‘External API Requests’ in the Settings page and click on the ‘New API Request’ button.
- The ‘New API Request’ page appears. Enter the API name under the ‘Request Title’ box.
- Select an appropriate method from the ‘Method’ box for the API call. You can use the following methods:
• GET – to retrieve the data from an external system
• POST– to write data
• PUT– to update data in the external system
- Enter the ‘Target URL’ for the API endpoint. Optionally, you can also enter a dynamic URL that includes parameters and variables in the Target URL field.
- Once you enter a dynamic URL, the URL parameters will appear under the ‘Parameter Keys’ section in read-only fields.
- Under Authentication, select one of the two available options:
• Basic Auth: Enter the Username and Password
• Custom Auth: Enter the custom username and password.
- You can also add keys for the API Parameters which you want to pass with Requests by using the Parameter Key button. Although it is not mandatory to enter Parameters, however, it is recommended to add at least one parameter.
- Click the ‘+ Query Parameter Key’ button to add the Query Parameter key, if required. Once you click the button, an editable query parameter row appears at the bottom.
- Click ‘Next’ after completing the above steps.
- In order to test the API set up, you can enter dummy values. For example, if the Parameter value is a date, then use the date-picker to enter a date.
- The Status Code and Response Body both are displayed when the API request is successful.
- In case the test fails, then you can edit the sample values and click the ‘Test Again’ button.
Note: In order to proceed to the next step, ensure that you get a successful status code API response in the Status box.
- Click ‘Next’, the application displays the API response.
- Successful API Response code is 2XX and it includes all the selected keys.
- Select the keys that you want to use in the Custom Bots. It is also supported that you do not select any keys, especially in POST / PUT scenarios.
- In case of a failure, the API Response code is either 3XX, 4XX, and 5XX.
- Click ‘Save’. The new API appears under the ‘New API Request’ list.
For more information, refer to Custom Bots API.