vania-janet/multiturn-rag-retrieval-data huggingface dataset:
To fire a remote trigger, you can call the fireTrigger method, and pass in parameters as needed by using a dictionary.

// In this example we are firing a trigger when our location has changed by a certain amount
var locationParams = Dictionary<String, String>()
locationParams["payload"] = "{"lat":41.27093, "lon":-73.77763}"
do {
try whisk.fireTrigger(name: "locationChanged", package: "mypackage", namespace: "mynamespace", parameters: locationParams, callback: {(reply, error) -> Void in
if let error = error {
print("Error firing trigger (error.localizedDescription)")
} else {
print("Trigger fired!")
}
})
} catch {
print("Error (error)")
}

In the previous example, you are firing a trigger that is called locationChanged.





 Use mobile SDK actions that return a result 

If the action returns a result, set hasResult to true in the invokeAction call. The result of the action is returned in the reply dictionary, for example:

do {
try whisk.invokeAction(name: "actionWithResult", package: "mypackage", namespace: "mynamespace", parameters: params, hasResult: true, callback: {(reply, error) -> Void in
if let error = error {
//do something
print("Error invoking Action (error.localizedDescription)")
} else {
var result = reply["result"]
print("Got result (result)")
}
})
} catch {
print("Error (error)")
}

By default, the SDK returns only the activation ID and any result that is produced by the invoked action. To get metadata of the entire response object, which includes the HTTP response status code, use the following setting:
The API returns a response that includes information such as your environment ID, environment status, and how much storage your environment is using. Do not go on to the next step until your environment status is ready. When you create the environment, if the status returns status:pending, use the GET /v1/environments/{environment_id} method to check the status until it is ready. In this example, replace {apikey} with your service credentials, and replace {environment_id} with the environment ID that was returned when you created the environment.

curl -u "apikey:{apikey}" "{url}/v1/environments/{environment_id}?version=2019-04-30"





 Create a collection 

Next, use the POST /v1/environments/{environment_id}/collections method to create a collection. Think of a collection as a box where you store your documents in your environment. This example creates a collection that is called my-first-collection in the environment that you created in the previous step, and uses the following default configuration:



* Replace {apikey} with your service credentials.
* Replace {environment_id} with the environment ID for the environment that you created in step 1.



Before creating a collection you must get the ID of your default configuration. To find your default configuration_id, use the GET /v1/environments/{environment_id}/configurations method:

curl -u "apikey:{apikey}" "{url}/v1/environments/{environment_id}/configurations?version=2019-04-30"

When you have the default configuration ID, use it to create your collection. Replace {configuration_id} with the default configuration ID for your environment.

curl -X POST -u "apikey:{apikey}" -H "Content-Type: application/json" -d "{"name": "my-first-collection", "description": "exploring collections", "configuration_id":"{configuration_id}" , "language": "en_us"}" "{url}/v1/environments/{environment_id}/collections?version=2019-04-30"
For more information, see [Uploading saved customer responses](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infouploading-saved-customer-response).

The ability to upload example phrases and saved customer responses is also helpful if you're using the classic Watson Assistant and want to migrate your intents and entities to the new Watson Assistant. For more information, see [Migrating intents and entities](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-intents-entities).





 5 May 2022 

Success/failure variable for extensions
: Each call to a custom extension now returns a Ran successfully response variable, which you can use to check the success or failure of the call. For more information, see [Checking success or failure](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-call-extensionextension-check-success).





 28 April 2022 

Definitive calculation for abandoned actions
: Abandonment is now definitively calculated for your actions. On the Analytics page, actions are no longer considered Ongoing in the action completion analysis. An action is considered abandoned if it was not completed after 1 hour of inactivity and doesn't meet the criteria for any other incompletion reason (escalated to agent, started a new action, or stuck on a step). This change applies only to actions data after April 26, 2022. For more information about action incompletion, see [Reasons for incompletion](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-analytics-action-completionincomplete-reasons).

Managing operations in extensions
: When you add a custom extension to an assistant, you can now choose which operations and response properties will be available to actions. For more information, see [Adding an extension to your assistant](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-add-custom-extension).





 21 April 2022 

Ability to duplicate a step
statusPayloadModel := &casemanagementv1.ResolvePayload{
Action: core.StringPtr("resolve"),
Comment: core.StringPtr("The problem has been resolved."),
ResolutionCode: core.Int64Ptr(int64(1)),
}

updateCaseStatusOptions := caseManagementService.NewUpdateCaseStatusOptions(
caseNumber,
statusPayloadModel,
)

caseVar, response, err := caseManagementService.UpdateCaseStatus(updateCaseStatusOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(caseVar, "", " ")
fmt.Println(string(b))

const statusPayloadModel = {
action: 'resolve',
comment: 'The problem has been resolved.',
resolution_code: 1,
};

const params = {
caseNumber: caseNumber,
statusPayload: statusPayloadModel,
};

caseManagementService.updateCaseStatus(params)
.then(res => {
console.log(JSON.stringify(res.result, null, 2));
})
.catch(err => {
console.warn(err)
});





 Support case status types 

When your response to an update in your support case is needed, the status is displayed as Waiting on client. If you don't provide a response within seven days, the status is updated to Resolved. The case is then closed if there's still no response after seven more days. For a description of each status type, see the following table:



Table 2. Support case status types

 Status Description 

 New A created case not yet viewed by a support engineer. 
 In progress A case that is under review.
// get me 5 documents up to _id order00077
PostAllDocsOptions docsOptions3 =
new PostAllDocsOptions.Builder()
.db("orders")
.endKey("order00077")
.limit(5)
.build();
AllDocsResult response3 =
service.postAllDocs(docsOptions3).execute().getResult();
System.out.println(response3);
const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

// get me 5 documents from _id order00057 onwards
service.postAllDocs({
db: 'orders',
startKey: 'order00057',
limit: 5
}).then(response1 => {
console.log(response1.result);
});

// get me 5 documents from _id order00057 onwards
service.postAllDocs({
db: 'orders',
startKey: 'order00057',
endKey: 'order00077',
limit: 5
}).then(response2 => {
console.log(response2.result);
});

// get me 5 documents up to _id order00077
service.postAllDocs({
db: 'orders',
endKey: 'order00077',
limit: 5
}).then(response3 => {
console.log(response3.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

 get me 5 documents from _id order00057 onwards
response1 = service.post_all_docs(
db='orders',
start_key='order00057',
limit=5
Scroll to the end of the output and copy any errors or stack traces.



* Provide the network response:



1. While you inspect the page, click the Network tab.
2. Refresh the page and reproduce the problem.
3. Starting at the end of the list, click each request and view the Preview tab. If the request has an "errors" node, expand that node to show the full error.
4. Click the Response tab and include the full response string and the URL that generated the response.









 Creating a support case for non-UI issue 

Collecting the following information can help a faster support case resolution for non-UI issues,



* guid
* collection_id
* Region of the instance
* environment_id
* property_id ((if the issue is related to property or evaluation)
* feature_id (if the issue is related to feature or evaluation)
* segment_id (if the issue is related to segment or evaluation)
* Error message received
If you don’t get a successful response, the error response contains the errors that you need to resolve. Resolve those errors and run the script until you are able to get a valid response and generate a plan.
8. If you want to check the logs of the action, see [Retrieving action logs with Schematics API](https://cloud.ibm.com/docs/hpc-spectrum-scale?topic=hpc-spectrum-scale-retrieve-action-logs) to retrieve the logs. The response contains the status of the action, and it appears in either a COMPLETED or FAILED state.





 Example Python request 

 Generate a plan using Schematics Python API

import json, logging

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_schematics.schematics_v1 import SchematicsV1

logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)

authenticator = IAMAuthenticator('<ibmcloud-api-key>')

schematics_service = SchematicsV1(authenticator = authenticator)

schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')

logging.info("Started Generating Schematic Plan")

workspace_activity_plan_result = schematics_service.plan_workspace_command(
    w_id='<workspace id>',
    refresh_token='<refresh-token>'
).get_result()

print(json.dumps(workspace_activity_plan_result, indent=2))

logging.info("Completed Generating Schematic Plan")





 Example Python response 

INFO:root:Started Generating Schematic Plan
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): iam.cloud.ibm.com:443
-d '{ "name": "My preset", "channels": ["<CHANNEL>"] }'

Where <PRESET_ID> is the presetid value returned when [running the GET method to return all presets.](https://cloud.ibm.com/docs/activity-tracker?topic=activity-tracker-preset-apipreset-api-get-all)

A response similar to the following is returned:

{"name":"Send by email","channels":[{"integration":"email","immediate":false,"terminal":true,"triggerlimit":1,"triggerinterval":30,"operator":"presence","emails":"AnotherUser@mycompany.com","alertid":"6043b60788"}],"presetid":"291a4100b0"}

If the <PRESET_ID> does not exist, the following is returned:

{"error":"Resource Not Found","code":"NotFound","status":"error"}





 Deleting a preset 

The following sample deletes a preset.

curl --request DELETE https://api.us-south.logging.cloud.ibm.com/v1/config/presetalert/<PRESET_ID> 
-H "Accept: application/json" 
-H "servicekey: <SERVICE_KEY>" 

Where <PRESET_ID> is the presetid value returned when [running the GET method to return all presets.](https://cloud.ibm.com/docs/activity-tracker?topic=activity-tracker-preset-apipreset-api-get-all)

The following response will be returned when the preset is successfully deleted:

{"deleted":true}

If the <PRESET_ID> does not exist, the following is returned:

{"error":"Resource Not Found","code":"NotFound","status":"error"}
feature.getFeatureDataFormat(); // YAML
feature.getCurrentValue(entityId, entityAttributes);





 Property 

const property = appConfigClient.getProperty('json-property');
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // JSON

// Example (traversing the returned JSON)
let result = property.getCurrentValue(entityId, entityAttributes);
console.log(result.value.key) // prints the value of the key

const property = appConfigClient.getProperty('yaml-property');
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // YAML
property.getCurrentValue(entityId, entityAttributes);





 Listen to the feature or property changes 

The SDK provides an event-based mechanism to notify you in real-time when feature flag's or property's configuration changes. You can listen to configurationUpdate event by using the same appConfigClient.

appConfigClient.emitter.on('configurationUpdate', () => {
// add your code
// To find the effect of any configuration changes, you can call the feature or property related methods

// feature = appConfigClient.getFeature('online-check-in');
// newResult = feature.getCurrentValue(entityId, entityAttributes);
});
Preparing JavaScript apps 

Before you create an action, get your JavaScript code ready. Confirm that your code is structured properly, then decide whether it needs packaged.



 Structuring JavaScript code 



* The expected name for the entry point function is main. If the function in your code is not main, take note of the name to specify it when the action is created.
* The input parameters are passed as a JSON object.
* The result of a successful activation is also a JSON object but is returned differently depending on whether the action is [synchronous](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prepprep_js_sync) or [asynchronous](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prepprep_js_async).



Example

function main() {
return {payload: 'Hello world'};
}

Example with multiple functions

function main() {
return { payload: helper() }
}

function helper() {
return new Date();
}





 Structuring JavaScript code with synchronous behavior 

The JavaScript activation is synchronous when the main function either exits without executing a return statement or exits by executing a return statement that returns any value except a promise.

Example of synchronous code

// each path results in a synchronous activation
function main(params) {
if (params.payload == 0) {
return;
} else if (params.payload == 1) {
return {payload: 'Hello, World!'};
} else if (params.payload == 2) {
return {error: 'payload must be 0 or 1'};
}
}





 Structuring JavaScript code with asynchronous behavior 

JavaScript functions can continue to run in a callback function even after a return. The JavaScript activation is asynchronous if the main function exits by returning a promise.
return new Response(hello ${postData.get('key')})
} catch (err) {
return new Response('could not unbundle post data')
}
}
Show more

Creating an HTTP POST request from an Edge function:

addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})

/
* Create a POST request with body 'key=world'
* Here, we are assuming that example.com acknowledges the POST request with body key=world
/
async function fetchAndApply(request) {
let content = 'key=world'
let headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
const init = {
method: 'POST',
headers: headers,
body: content
}
const response = await fetch('https://example.com', init)
console.log('Got response', response)
return response
}
Show more





 Signed requests 

A common URL authentication method known as request signing can be implemented in an Edge function with the help of the Web Crypto API.

In the example presented here, we’ll authenticate the path of a URL along with an accompanying expiration timestamp, using a Hash-based Message Authentication Code (HMAC) with a SHA-256 digest algorithm. For a user agent to successfully fetch an authenticated resource, they’ll need to provide the correct path, expiration timestamp, and HMAC using query parameters — if any of those three are tampered with, the request fails.

Note that the authenticity of the expiration timestamp is covered by the HMAC, so we can rely on the user-provided timestamp being correct if the HMAC is correct, and thus know when the URL expires. Moreover, you can also determine whether a URL in their possession has expired or not.



 Verifying signed requests
If the return type is ScalarList, specify the input parameter from which the scalar type inside the ScalarList is to be inferred. When the language is PMML, the function must return a table.
* <output-schema-definition>

For table UDFs, the <output-schema-definition> specifies the output schema of the table that is returned by the UDF, including the column names and their types.
* <ext-name>

The external_name specifies where to find the implementation of the UDF. When the language is Java, it is a string of the form '<jar-file-name>:<fully-qualified-class-name>!<method-name>', which consists of three parts:



* JAR file name: When you compile modular AQL, the location references of UDF JAR files must be relative to the root of the module in which the reference is made.
* Class name: Fully qualified class name that contains the UDF implementation
* Method name: The method must be a public method of the class. The method signature must match the parameter types that are specified in the create function statement. Automatic type conversion is not done by the runtime component. When the language is PMML, the external_name clause specifies a string that is the location of the PMML file relative to the module’s root directory. The current implementation supports models that are expressed by using the PMML standard version 4.1 and evaluates them using the version 1.0.22 org.jpmml library.



* language

The language specification points to the language of implementation of the UDF. The runtime component supports only UDFs that are implemented in Java™.
* deterministic/not deterministic

The optional deterministic/not deterministic specifies whether the function is stateless. A deterministic function always returns the same value for the same set of input values.
* return null on null input

The optional return null on null input specifies the function behavior when one or more of the input values are null. If return null on null input is specified, the system returns null on null input without invoking the UDF.
* Get data from another application or service.



For information about how to call an external service, such as a Cloud Functions web action, see [Making a programmatic call from a dialog node](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-dialog-webhooks).

The following diagram illustrates how you can use a client call to get weather forecast information, and return it to the user.

![Shows someone asking for a weather forecast, the dialog sending a request to a client app, which sends it to the external service](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/forecast.png)

Note that the client action calls the MyWeatherFunction program, which is a program that the client application runs. The client application makes the call to the external web service (/weather) to get the actual forecast information. The client application then returns the response to the dialog. When you add a client action to a dialog, a client application must exist that either does the processing itself or that passes information between your dialog and any external back-end services that you want to use.



 Procedure 

To make a programmatic call to a client application from a dialog node, complete the following steps:



1. In the dialog node from which you want to make the programmatic call, open the JSON editor.



* To make a programmatic call that runs after the response for a node is evaluated, open the JSON editor for the node response.

![Shows how to access the JSON editor associated with a standard node response.](https://cloud.ibm.com/docs-content/v1/content/a2b18c153837bce00a5b4de496e4b4ca64bbf56e/assistant-data/images/contextvar-json-response.png)

If the Multiple responses setting is On for the node, then you must click the Edit response!
listResourceInstancesOptions := resourceControllerService.NewListResourceInstancesOptions()
listResourceInstancesOptions = listResourceInstancesOptions.SetName(resourceInstanceName)

resourceInstancesList, response, err := resourceControllerService.ListResourceInstances(listResourceInstancesOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(resourceInstancesList, "", " ")
fmt.Printf("nListResourceInstances() response:n%sn", string(b))

const params = {
name: resourceInstanceName,
};

resourceControllerService.listResourceInstances(params)
.then(res => {
console.log('listResourceInstances() response:n' + JSON.stringify(res.result, null, 2));
})
.catch(err => {
console.warn(err)
});
6. You get an activity ID in response if the parameters passed as part of the request are valid. You should see the plan being applied in the Schematics workspace that you created in the IBM Cloud console. If you don’t get a successful response, the error response contains the errors that you need to resolve. Resolve those errors and run the script until you are able to get a valid response and apply a plan.
7. If you want to check the logs of the action, see [Retrieving action logs with Schematics API](https://cloud.ibm.com/docs/hpc-openshift?topic=hpc-openshift-retrieve-action-logs&interface=api) to retrieve the logs. The response contains the status of the action, and it appears in either a COMPLETED or FAILED state.





 Example Python request 

 Apply a plan using Schematics Python API

import json, logging

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_schematics.schematics_v1 import SchematicsV1

logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)

authenticator = IAMAuthenticator('<ibmcloud-api-key>')

schematics_service = SchematicsV1(authenticator = authenticator)

schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')

logging.info("Started Applying Schematic Plan")

workspace_activity_apply_result = schematics_service.apply_workspace_command(
    w_id='<workspace id>',
    refresh_token='<refresh-token>'
).get_result()

print(json.dumps(workspace_activity_apply_result, indent=2))

logging.info("Completed Applying Schematic Plan")





 Example Python response 

INFO:root:Started Applying Schematic Plan