Skip to main content
Merative SPM Virtual Assistant

Test an action directly in IBM Cloud Functions

You might want to modify the existing sample Javascript code that is provided to call your own custom REST APIs or display different fields in the chatbot based on your own requirements. You will then want to test that your action works as expected.

As part of the IBM Cloud Functions service, you can directly invoke each of the actions you created and view the expected JSON or HTML format that is returned from each request. Although the steps outlined on this page detail how to test one of the sample actions provided, the same concepts can be used to test your own Cloud Functions actions.

Testing the sample actions

Further details about the sample actions provided can be found in the Cloud Function overview section.

The following list summarizes the steps to test an action using the IBM Cloud Functions service:

  • Generate a JWT in SPM and copy the value for use as an authorization parameter when invoking the action.
  • Retrieve values for the other parameters you want to send. Different flows will be invoked depending on the parameters used.
  • In the IBM Cloud Functions service, add all parameters to a JSON object.
  • Invoke the action and view the response.

Further details for each of these steps are in the following sections.

You can test the caseworker action, which will in turn invoke one of the person or verifications actions under the hood, or you can test either of the person or verifications actions directly.

How to generate an authorization token to use when invoking the action

Before you invoke any of the actions, you need to get a valid JWT to add as an authorization parameter. This is required for the action to be able to access the underlying REST API in the SPM server.

The following list outlines how to retrieve a valid JWT from SPM to use when invoking the actions:

  1. In your SPM application, log in with the user that you enabled to be displayed as the virtual assistant for example, caseworker.
  2. From your browser > Developer Tools, open the Network section and select the clear icon.
  3. Open the Virtual Assistant web chat and select Outstanding verifications by case.
  4. By viewing the request headers in the Network section for the request to Watson Assistant, you can copy the value for the authorization request header. You do not need to include the ‘Bearer’ scheme, just the value of the token.
Authorization

Figure 1: Authorization.

Determine parameters for the flow you want to test and add to a JSON object

The Cloud Function action accepts parameters as a JSON object only. Determine the parameters you need to test the required action and flow. Add them, along with the appropriate authorization parameter, to a JSON object.

Parameters and flows for the caseworker action

The following table lists the possible flows through the caseworker action that you can test and the parameters required to invoke the flow. In addition, a __ow_headers parameter containing a nested JSON object with a valid authorization token value (without the ‘Bearer’ scheme) is required.

FlowParameters to invoke the flowParameter detailsExample of parameters in JSON format
1. Retrieve a person’s details by using one of their identifiersidentificationID
identificationIDType
You can retrieve the identificationID, which is also known as the alternateID, from a person’s evidence page in SPM.

The identificationIDType parameter is an optional string parameter. Based on the sample code, the value must be one of passport, drivers licence or SSN. Under the hood, the string gets mapped to a corresponding code from the ConcernRoleAlternateID codetable in SPM, which is required by the underlying REST API that the action invokes. Any other string value will get mapped to a default code of CA7. If this parameter is not used, the default code of CA7 will be used.
{"identificationID":20001, "identificationIDType":"Passport", "__ow_headers":{"authorization":"<token_value>"}}
2. Retrieve a case and primary client’s details by using the case reference numbercaseReferenceYou can retrieve the case reference number when you view the Integrated Case in SPM.{"personID" : "564543246789865439", "__ow_headers":{"authorization":"<token_value>"}}
3. Retrieve verification details for a personpersonIDYou can retrieve the personID, which is also known as the concernRoleID, from the person home page in SPM if you have the SPM UI Inspector tool configured, or from the ConcernRole database table.{"caseReference" : "55555", "__ow_headers":{"authorization":"<token_value>"}}
4. Retrieve verification details for a casecaseIDYou can retrieve the caseID from the case home page if you have the SPM UI Inspector tool configured, or from the CaseHeader database table.{"caseID" : "8362543246789865439", "__ow_headers":{"authorization":"<token_value>"}}

Parameters and flows for the person action

The following table lists the flows through the person action that you can test and the parameters required to invoke the flow. A valid authorization parameter is required in each action. Note that the format of this parameter differs slightly from the caseworker action.

FlowParameters to invoke the flowParameter detailsExample of parameters in JSON format
1. Retrieve a person’s details by using one of their identifiersidentificationID
identificationIDType
You can retrieve the identificationID, which is also known as the alternateID, from a person’s evidence page in SPM.

The identificationIDType parameter is an optional string parameter. Based on the sample code, the value must be one of passport, drivers licence or SSN. Under the hood, the string gets mapped to a corresponding code from the ConcernRoleAlternateID codetable in SPM, which is required by the underlying REST API that the action invokes. Any other string value will get mapped to a default code of CA7. If this parameter is not used, the default code of CA7 will be used.
{"identificationID":20001, "identificationIDType":"Passport", "authorization":"Bearer <token_value>"}
2. Retrieve a case and primary client’s details by using the case reference numbercaseReferenceYou can retrieve the case reference number when you view the Integrated Case in SPM.{"personID" : "564543246789865439", "authorization":"Bearer <token_value>"}

Parameters and flows for the verifications action

The following table lists the flows through the verifications action that you can test and the parameters required to invoke the flow. A valid authorization parameter is required in each action. Note that the format of this parameter differs slightly from the caseworker action.

FlowParameters to invoke the flowParameter detailsExample of parameters in JSON format
1. Retrieve verification details for a personpersonIDYou can retrieve the personID, which is also known as the concernRoleID, from the person home page in SPM if you have the SPM UI Inspector tool configured, or from the ConcernRole database table.{"caseReference" : "55555", ""authorization":"Bearer <token_value>"}
2. Retrieve verification details for a casecaseIDYou can retrieve the caseID from the case home page if you have the SPM UI tool configured, or from the CaseHeader database table.{"caseID" : "8362543246789865439", "authorization":"Bearer <token_value>"}

Invoke the Cloud Function action with parameters

  1. From Functions > Actions > curam-rest package, select the action to be tested.
  2. Click the Invoke with parameters button.
  3. From the Change Action Input window, enter a JSON object containing the parameters you want to send and click Apply.
Invoke-with-parameters

Figure 2: Invoke with parameters.

4. Click the `Invoke` button.

Sample expected results

The following figures include some sample results retrieved by invoking the different actions based on sample data that is configured in the application.

Person-results-by-identification-id

Figure 3: Person results by using the identification number.

Person-results-by-case-reference

Figure 4: Person results by using the case reference number.

Verification-results-by-person-id

Figure 5: Verification results by using the person number.

Verification-results-by-case-id

Figure 6: Verification results by using the case number.