Generic Cognitive Services
Generic Cognitive Services activity is used to consume cognitive REST APIs of different providers. If there are any newly launched APIs in the market and it is not available in our product, then you can use this activity to consume the API.
NOTE: |
To use Generic Cognitive Service, service API details are required. |
Using Generic Cognitive Service
- In the Canvas Tools pane, click Process Components to expand and view the associated activities.
- Drag the Application activity and drop on to the Flowchart designer area on the Canvas.
- In the Application Type list, select CognitiveApps.
- In the Select An Application list, select application.
- Double-click the Application activity to add Vision activity as cognitive activities works inside the application activity.
- In the Canvas Tools pane, click Cognitive Services to expand the tool and view the associated activities.
- Drag the Generic Cognitive Service activity and drop on to the Flowchart designer area on the Canvas.
- In the Provider list, select the Provider name. By default, the provider is set to Google.
Automation Studio supports two service providers for Generic Cognitive Service.- Microsoft
- In the Response Header list, select the response header file for the API call. This file provides JSON for all the headers in the response.
- In the Response list, select the response file for the API call. This file provides body of the response.
- Click the
(Settings) icon. The Configuration window appears.
To configure API service:
- Https Method: The request made by the API for retrieving or sending data to the server. By default, Get is selected.
- GET - Retrieves data from the server.
- POST - Sends data to the server for creating new resource.
- PUT - Updates an existing resource.
- DELETE - Deletes data or resource from the server.
- Url of API: An API is accessed via URL where you can form the endpoint of the API URL by passing the resource as a query parameter or by simply stating the actual value of the endpoint. It is an expression textbox where a VB scripts can be entered such as, baseurl+”? language=en-US&format=detailed" where baseurl is an argument concatenated with string literal.
- Stream File: Enables to stream the API response as a binary stream. This option is available only for Https Methods-POST, PUT and DELETE. If it is enabled, the Body tab of the Configuration dialog box, remains disabled. This is an optional field which is used with endpoints like Microsoft’s Speech to Text.
- Stream Source File: This field is available only when Stream File is enabled. Select the parameter that contains the path of the streaming file. You must define the parameter of string type, in the Parameter bar to use this option.
- Convert File to Base64 Encoding: This field is available only when Stream File is disabled and is an optional field. It helps you to encode the file required by the endpoint, to the Base64 format and then add the file as JSON value in the request body.
- Source File: Select the parameter that contains the path of the file that needs to be converted to the Base64 encoding. You must define the parameter of string type, in the Parameter bar to use this option.
- Output Argument: Select the parameter to store the Base64 encoded string of source file. You must define the parameter of string type, in the Parameter bar to use this option.
- Header: Signifies the information related to the API request and response.
- Key - Enter the name of the header. Once the name is entered, a new line item is available.
- Value - In the Value list, select the parameter containing the value of the header. You must define a parameter in the Parameter bar to use this option. Alternatively, select the check box to enter the value of the header to set it as the default value.
- Description - Enter a small description of the header. This field is only for informative purpose and is not used in any form while consuming an endpoint.
- Body: Signifies the custom view that contains information that you want to send to the server. This field is disabled for GET Https method. This field is disabled if Stream Files is enabled for any of the Https methods.
- In the Body Type list, select the type of response to be sent to the server. Available options are:
- JSON - The request is sent in JSON format.
- Others - The request is sent in any other format such as xml, ssml and others.
- If Body Type selected is JSON.
- In the Raw Input JSON field, enter the sample or the template JSON request.
- Click the
(Click to convert JSON) icon to transform the sample JSON to formatted JSON. Additioally, the validation of the JSON is done once you transform the sample data.
- In the Tansformed JSON field, the transfomed and validated JSON is available for parameterizing the request body as shown in the sample Argument pane below.
Following is the sample of the Raw JSON formatted without parameters:
Following is the sample Argument pane:
Following is the sample of the Raw JSON formatted with parameters:
- If Body Type selected is Others, in the Raw field, enter the request body in any other format to send to the server.
- Download File: Enable the Download File option when response of the endpoint is a binary data file. The Download Filepath field appears.
In the Download Filepath list, select the parameter containing the file path along with the file name to store the binary data file. You must define a parameter in the Parameter bar to use this option.
Generic Cognitive Service Properties
The properties of Generic Cognitive Service activity are listed in the following table and can be edited in the Properties grid on the right pane.
Property Name |
Usage |
Control Execution |
|
Ignore Error |
When this option is set to Yes, the application ignores any error while executing the activity. If set to NA, it bypasses the exception (if any) to let the automation flow continue; however, it marks the automation status as failure, in case of an exception. By default, this option is set to No. |
Delay |
|
Wait After (ms) |
Specify the time delay that must occur after the activity is executed. The value must be in milliseconds. |
Wait Before (ms) |
Specify the time delay that must occur before the activity is executed. The value must be in milliseconds. |
Misc |
|
ApplicationID |
It is internally created and managed by Automation Studio itself. |
Breakpoint |
Select this option to mark this activity as the pause point while debugging the process. At this point, the process freezes during execution allowing you to examine if the process is functioning as expected. In large or complex processes, breakpoints help in identifying the error, if any. |
Commented |
Select this option to mark this activity as inactive in the entire process. When an activity is commented, it is ignored during the process execution. |
DisplayName |
The display name of the activity in the flowchart designer area. By default, the name is set as Generic Cognitive Service. You can change the name as required. |