IBM Watson Assistant: How can I filter messages for "anything else"? - ibm-cloud

In Analytics > User conversations, I would like to filter out the messages which my Watson Assistant was unable to answer in its conversations, i.e., when it returns the anything_else reply.
But since anything_else is not an intent nor an entity, I can't filter messages by it in the UI. Is it possible to therefore filter messages by the assistant's reply, like you can with user statements? That way I can filter out each time the assistant answered "I don't understand".

IBM Watson Assistant offers the log in the Analytics section of it UI and, IMHO more powerful, via REST API with filter expressions. With that API you can either download all logs and filter "offline" or apply some expressions. I recommend reading the documentation about how to query the "other" fields which includes the user responses.
I have written Python tools for Watson Assistant using the V1 and V2 APIs. The V1 tool is able to download or query the logs. An option is to download all available logs, then use jq to filter them.
python wctool.py -logs -config config.json.event -id 28ac4bcb-2aae-41aa-87ac-2e6074e1356a > logs201904.out
This gives you the information about which nodes were visited:
cat logs201904.out | jq -r '.logs | .[]
| .response.output.nodes_visited '
Filter for log records that visited "Anything else":
cat logs201904.out | jq -r '.logs | .[] | .response | select(
.output.nodes_visited[] | contains("Anything else")) '

anything_else means either an intent was not found, or the confidence was < 0.2.
Filter looking for intents = [], or confidence of first intent is below 20%

Related

Owasp Zap Testing rest api

Is that possible to testing rest-api via OWASP ZAP ?
Url to attack worked just for GET requests.
For example, my api controllers work with only token. I have TokenController and this controller require POST data via JSON data include password and login. Can I someway testing this controller via OWASP ?
The short answer is yes. The long answer - it's complicated :)
Testing REST API is a bit harder than testing web API - you'll have to give Zap information about your API - which endpoints it has, parameters, etc. Can you share more about you're API? Does it have OpenAPI/Swagger document? Do you have existing tests? You can use either one of those for this task.
I gave a talk about how this can be achieved - you can find the recording here.
It possible to automate API testint with OWASP ZAP, but to perform the tests, I see two options: Offer some usage pattern, for example OpenAPI for ZAP consider extracting the information. And a second option would be to run an automated test to capture ZAP as passive scan information, and after that you can test the session information.
We recommend using the OpenAPI documentation.
The cucumber test would look like this:
Feature: Security
This feature is to test pokemon service security
Scenario: Validate passive and active scan
Given I import context from open API specification "/v2/api-docs"
And I remove alerts
| url |
| http://.*/v2/api-docs* |
And I import scan policy "javaclean" from file "javaclean.policy"
When I run active scan
And I generate security test HTML report with name "java-clean-security-report"
Then the number of risks per category should not be greater than
| low | medium | high | informational |
| 0 | 0 | 0 | 0 |
I am develop step for ZAP, view in the GitHub: https://github.com/osvaldjr/easy-cucumber/wiki/Security-steps
Example step for import OpenAPI docs:
#Given("^I import context from open API specification \"([^\"]*)\"$")
public void iImportContextFromOpenAPISpecification(String path)
throws ClientApiException, InterruptedException {
String url = getTargetUrl() + path;
log.info("Import Open API from url: " + url);
zapProxyApi.openapi.importUrl(url, null);
waitPassiveScanRunning();
verifyThatTheProxyHasCapturedHostInformation();
}
View others steps in: https://github.com/osvaldjr/easy-cucumber/blob/master/src/main/java/io/github/osvaldjr/stepdefinitions/steps/SecuritySteps.java

Retrieve service tags for a given node from consul API with jq

I am trying to retrieve ServiceTag(s) for a given Node from consul API. I need through jq filtering.
Here is jq play query for Node & Service tag, but i want ServiceTag for a given Node..
With service tag - https://jqplay.org/s/iaSIPnkxFm
With node - https://jqplay.org/s/ea-LyKhhpy
Can anyone please help me with jq query to combine both to give the service tag "my-app-tag" for the node "my-app-1-2-3-4" in the above the example.
Unfortunately the given data, the given problem description, and the given answer do not quite agree with each other, perhaps because of a typo.
However, the problem description corresponds to a query of the form:
.[].Checks[] | select(.Node == $NODE) | .ServiceTags[]
For example, with your data, and letting $NODE have the value "my-ap-1-2-3-4", the jq query:
.[].Checks[] | select(.Node == "my-ap-1-2-3-4") | .ServiceTags[]
yields:
"my-app-tag"

How to limit Bing Search API V5 to search specific sections of the website

Using bing.com, I can do a search like this (click here for link):
history site:berkeley.edu/about/
When I try the same using the API, I get very different results. As far as I can tell, the search results returns webpages that are not hosted in berkeley.edu (see bottom).
this is the HTTP GET request being made to Azure
https://api.cognitive.microsoft.com/bing/v5.0/search?q=history+site:berkeley.edu/about/&count=10&offset=0
This is my HTTP GET code
$.ajax({
url: "https://api.cognitive.microsoft.com/bing/v5.0/search"
, data: { "q":encodeURI("history+site:berkeley.edu/about/"), "count":"10", "offset":"0" }
, beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","supply-your-key-here");
}
, type: "GET",
})
Any ideas what I could be doing wrong? Thanks
edit1: Seems my "problem" is related to the way AJAX is making the HTTP request. If I supply my key by using a Firefox header plugin and type this (https://api.cognitive.microsoft.com/bing/v5.0/search?q=history+site:berkeley.edu/about/&count=10&offset=0) on my browser URL box, I get the correct response.
search results using API
Environmental Design Library | UC Berkeley Library: A branch of the UC Berkeley Library system, the Environmental Design Library supports the research and teaching of the College of Environmental Design.
Proceedings Template - WORD - ideals.illinois.edu: "(c) ACM, 2007. This is the authors’ version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution.
Trends in metadata practices: A longitudinal study of ...: Trends in metadata practices: A longitudinal study of collection federation. ... A Longitudinal Study of Collection Federation Carole Palmer Oksana ...
http://aerospaceutility.tripod.com/ · GitHub: Clone via HTTPS Clone with Git or checkout with SVN using the repository's web address.
HS RWC Colorado Sample Instructional Units - LiveBinder: Loading Livebinder HS RWC Colorado Sample Instructional Units HS Read Write Communicate Sample Instructional Units provided by the Colorado Department of Education.
Arroyo High School: News Archive: News Archive SIA Awards "As the school year comes to a close, the Students in Action club would like to honor three students for their lasting impact on our ...
English 12 (exp) | Utah Electronic High School: Please be mindful of the fact that this course is not a credit "quick fix." It is a rigorous, college-preparatory class that is both time and labor intensive.
Working SMARTer, not Harder: SOCIAL STUDIES ONLINE ...: SOCIAL STUDIES ONLINE RESOURCES AND LINKS COMPILATION beta List of Social Studies online resources and links to professional development opportunities ...
The Big List -- 20121008 - Grolier: The Big List -- 20121008: 1: EA: http://www.stanford.edu/group/bipolar.clinic/ Stanford Bipolar Disorders Clinic: 2: EA: http://www.mhsource.com/bipolar/
Spreadsheet of Conference Attendees - studylib.net: ÐÏ à¡± á > þÿ ] þÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ...
You can use Bing custom search alternately to make sure you get results only from the domain/webpages you want. Here is the call: https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search. You will need a different accesskey though, which you can get from customsearch.ai.
I'm getting correct results on both v5.0 and v7.0.
There seems nothing wrong with your query.
https://api.cognitive.microsoft.com/bing/v5.0/search?q=history+site:berkeley.edu/about/&count=10&offset=0
Perhaps you are caching results somewhere in your browser?
Update: Since IE does it, but Firefox doesn't. Have you disabled cache on IE?

Sorting results returned by Yarn's REST API

I wanted to get every application that was run on the ResourceManager. I am using the REST API that comes with Yarn, specifically
http://<rm http address:port>/ws/v1/cluster/apps
This API call returns the results that I am looking for. But I would like to sort it by start time in descending order. The result that I get is not sorted in any particular order (I think it is sorted lexicographically using the application id, but I am not sure). The documentation gives a list of parameters that the API accepts but I don't see any method to sort the results. If the REST API does not support sorting, then is there any other way to sort the results?
The documentation I am following is this
https://hadoop.apache.org/docs/r2.7.0/hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html
Assuming you get the response in json format, you can sort it using python!
http://<rm http address:port>/ws/v1/cluster/apps | python -c "import json,sys;from pprint import pprint; pprint(sorted(json.load(sys.stdin)['apps']['app'], key=lambda k: k['startedTime'], reverse=True))"|grep id
If you are using command line, you can use jq:
curl 'http://<rm http address:port>/ws/v1/cluster/apps' | jq '.apps.app | sort_by(-.startedTime)'

RESTful service for PUT/PATCH with image upload - testing with Postman

I am trying to test an app with RESTful services via Postman (awaiting the front-end to be implemented).
The GET/POST and DELETE requests work as expected, but when it comes to PUT and PATCH I'm completely stuck.
I have a simple form with several inputs and files (pdf & image). With the POST request I simply use the "form-data" body to add all needed parameters. But when I try to test the PUT one, "form-data" detects nothing - with or without a "Content-Type" = "multipart/form-data" set in the header.
The PUT only works with the "x-www-form-urlencoded" option for the body, but then I cannot or don't know how to add both files, as I don't have the ability to choose from "Text/File" anymore via Postman's dropdown. Again, adding Content-Type doesn't help a bit.
I tried simulating POST with a "_method"="PUT" both as a URL parameter and as a form input, but it just creates new item instead of updating existing one (with correct route applied).
# Updated with the routes (standard Laravel routes for RESTful services)
GET | api/v1/Collection | api.v1.collection.index
POST | api/v1/collection | api.v1.collection.store
GET | api/v1/collection/create | api.v1.collection.create
GET | api/v1/collection/{item} | api.v1.collection.show
PUT | api/v1/collection/{item} | api.v1.collection.update
DELETE | api/v1/collection/{item} | api.v1.collection.destroy
GET | api/v1/collection/{item}/edit | api.v1.collection.edit
I realize I have to use a hidden input with _method/PUT as key-value, but I have no idea where to add it in Postman. I can only see two options: text input or file.
What am I missing?
I can provide screenshots upon request. Thanks.