After logging into Xpoda Studio, click on the API Service area in the left menu. On the screen that opens, press the plus (+) icon just above the "Create a new API Collection" statement to create a new API collection. After this step, a small window will open where you can name the API Collection. Enter a name that clearly describes the purpose of the collection you are creating and confirm by clicking the 'Create and Go' button. This will create the basic collection where you can add API methods to be triggered by the Assistant.
In this example, the API Collection name is set to 'Test for API Assistant'. Click on the Collection to open the Request list. On this screen, the API Request is defined and the relevant URL is added. In this example, a GET call is made to list the 100 most popular movies from the IMDb site using the API request named ImdbTop100.
When you click on the IMDb Top100 request, the Request Detail screen (API definition screen) opens. On this screen, the necessary parameters and header information have been added to the Request Detail field of the selected API. These headers contain information that must be entered for the API to work correctly (x-rapidapi-host and x-rapidapi-key). These parameters are required to retrieve the IMDb Top 100 list via the API. The API's host address is entered in the x-rapidapi-host field, and the access key (API key) is entered in the x-rapidapi-key field.
After defining the API, the next step is to click on the Assistant field in the menu on the left to go to the Xpoda Assistant screen. On this screen, you can determine how the Assistant will process user commands, define commands (intents) and triggers, and connect the API you just created to the Assistant. This way, the API call can be automatically executed via the command given through the Assistant.
To define a new API on the Assistant screen, first enter the desired name in the Name field. Then, open the Type dropdown menu and select the Triggering API Engine option. After making this selection, the screen will change as shown in the second image, and the API Collection and API Request fields will become active. After checking the Active box, select the API collection you created earlier and the specific API request you want to run.
In this example, since the API does not take any parameters, the Api Parameters section is left blank.
In the Api Data Query field, you can write the query to be pulled from your own table to specify which data returned from the API you want to see. The query used in our example:
INSERT INTO dbo.XP_API_IMDB_MOVIE_LIST
(
CreateDate,
CreateUser,
UpdateDate,
UpdateUser,
IntegrationID,
ProjectID,
FormTypeID,
LineNumber,
RecordGuid,
MovieRank,
Title,
ReleaseYear,
ImdbRating,
FilmType,
DirectorName,
MovieLength
)
SELECT
GETDATE() AS CreateDate,
1 AS CreateUser,
GETDATE() AS UpdateDate,
GETDATE() AS UpdateUser,
0 AS IntegrationID,
0 AS ProjectID,
0 AS FormTypeID,
1 AS LineNumber,
NEWID() AS RecordGuid,
rank AS MovieRank,
Series_Title AS Title,
Released_Year AS ReleaseYear,
IMDB_Rating AS ImdbRating,
Genre AS FilmType,
Director AS DirectorName,
CAST(REPLACE(Runtime, ' min', '') AS DECIMAL(5,2)) AS MovieLength
FROM #XPODA_API_TABLE_2;
This query takes the information from the #XPODA_API_TABLE_2 table, which is temporarily created as a result of the API call, and adds it to the XP_API_IMDB_MOVIE_LIST table. This way, the IMDb Top 100 movie titles are saved to your system.
You can specify the frequency at which you want the API to run in minutes on the Assistant screen. To do this, click the Working Condition button in the top menu. On the screen that opens, enter a value such as 5 in the time field on the right to set the API to run every 5 minutes. After setting the time, click the save icon in the upper right to save your settings. The API will then be triggered automatically at the interval you specified.