Checkbox with watson - ibm-watson

I know that Watson is a powerful tool, but for different reasons I do not want to use all the power it offers. I want to know if it is possible to create checkboxes.
The idea would be to replace the users' text inputs with predefined choices.
I do not find anywhere to do that.
Thank you for your help.

Use the options output.
You can do this through the web UI IBM provides and there the output looks like this:
When you open it with the JSON editor it looks like this:
{
"output": {
"generic": [
{
"values": [
{
"text": "Some text."
}
],
"response_type": "text",
"selection_policy": "sequential"
},
{
"title": "demo",
"options": [
{
"label": "button1",
"value": {
"input": {
"text": "1"
}
}
},
{
"label": "button2",
"value": {
"input": {
"text": "2"
}
}
}
],
"response_type": "option"
}
]
}
}

Related

Update the context variable based on the return JSON

I need to update the JSON of a node in watson assistant based on the JSON that returns from my API.
Example: A node of my assistant has a response that shows a list of options, JSON below creates that list of options.
{"output": { "generic": [ { "title": "aaaaa", "options": [ { "label": "aaaaa", "value": { "input": { "text": "a" } } }, { "label": "bbbbb", "value": { "input": { "text": "b" } } } ], "response_type": "option" } ] } }
I need to change this JSON and put in it the JSON that comes from my API, example of JSON is below.
{"output": { "generic": [ { "title": "Relação de Cidades", "options": [ { "label": "São Paulo", "value": { "input": { "text": "SP" } } }, { "label": "Rio de janeiro", "value": { "input": { "text": "RJ" } } }, { "label": "Bahia", "value": { "input": { "text": "BA" } } } ], "response_type": "option" } ] }, "context": {} }
Or could I send this JSON that returns from the API straight into the conversation in such a way that it assembles the list of options that JSON creates ...?
I've tried to put this JSON in a variable and show the content of that variable in the conversation, but it shows the content of the JSON instead of assembling the list that JSON defines.
The result follows. I did it like this:
I appreciate any help, as I did not find any material on the Internet that would help me solve this.
You can just return this as a context variable and then quote that context variable inside another context variable.
Set the customisation that you want as $Variable1
then inside your context variable just specify the value as $Variable1

Alexa skills: No value returned for custom slot

Hopefully someone can help me with this because I've been stumped for a week.
I am creating a simple Alexa skill from one of the samples. It's the color picker skill - you tell Alexa your favorite color, and then you ask her your favorite color. I'm using Custom Slots, and the Skill Service doesn't want to return a value for the color. It launches successfully, and then loads the correct intent, however it doesn't send the correct value. Instead, there's not even a value parameter in the output, just name and confirmation status.
Here's my skill's JSON, followed by the request JSON output after I tell the skill: "My color is red." I want the skill to pass "red" into the value parameter.
{
"interactionModel": {
"languageModel": {
"invocationName": "color picker",
"intents": [
{
"name": "MyColorIsIntent",
"slots": [
{
"name": "color",
"type": "LIST_OF_COLORS"
}
],
"samples": [
"my color is {color}",
"{color} is my color"
]
},
{
"name": "WhatsMyColorIntent",
"slots": [],
"samples": [
"what's my color",
"what's my favorite color"
]
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
}
],
"types": [
{
"name": "LIST_OF_COLORS",
"values": [
{
"name": {
"value": "green"
}
},
{
"name": {
"value": "red"
}
},
{
"name": {
"value": "yellow"
}
},
{
"name": {
"value": "orange"
}
},
{
"name": {
"value": "black"
}
},
{
"name": {
"value": "blue"
}
}
]
}
]
}
}
}
Down below is the request:
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.918d6da6-cd7e-4bb8-a2a9-41fb1af8a354",
"timestamp": "2018-10-01T01:53:56Z",
"locale": "en-US",
"intent": {
"name": "MyColorIsIntent",
"confirmationStatus": "NONE",
"slots": {
"Color": {
"name": "Color",
"confirmationStatus": "NONE"
}
}
}
}
Your issue is that slot "color" should be named "Color" and your sample references changed to reflect this so "my color is {Color}", and "{Color} is my color", It is not picking up the slot because the name is identical.
Be sure to also complete the skill with the required Intents for stop and help, currently, this will just continue asking for color choices until you kill the program.
​This is what happened:
I was working on different versions of the same skill, each with the same invocation name. When I typed in the invocation name, it actually opened an outdated version of the skill (I hadn't deleted the old skills - I had like 3 different ones - I like to start over). I didn't realize that when you click "test" you can test any of your saved skills, not just the one you have open.

SchemaForm array conditional

Background
I am making a form using http://schemaform.io/
Setup
I am trying to make an array of objects that a user can make using a form. So, the user can add as many items into the array as they want.
The array of items contains a type, then another field depending on what the type was.
If the user clicks REST, I want it to offer a field called method.
If the user clicks SSH, I want it to offer a field called path.
Code so far
SCHEMA
{
"type": "object",
"title": "Command Asset",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"commands": {
"type": "array",
"title": "Actions",
"items": {
"type": "object",
"properties": {
"commandType": {
"title": "Command Type",
"type": "string",
"enum": [
"REST",
"SSH"
]
},
"path": {
"title": "Path",
"type": "string"
},
"method": {
"title": "Method",
"type": "string"
}
}
}
}
}
}
FORM
[
{
"type": "help",
"helpvalue": "<h5>Command</h5>"
},
"name",
{
"title":"Command",
"key": "commands",
"items": [
"commands[].commandType",
{
"type": "conditional",
"condition": "modelData.commands[0].commandType=='SSH'",
"items": [
{
"key": "commands[].path"
}
]
},
{
"type": "conditional",
"condition": "modelData.commands[0].commandType=='REST'",
"items": [
{
"key": "commands[].method"
}
]
}
]
}
]
One can test this code here: http://schemaform.io/examples/bootstrap-example.html
Question
As one can see, the code I have now makes all the items' secondary properties (path or method) dependent on the first item in the array's commandType (at [0]), but I want it to depend on the commandType of the corresponding item. So, if item one has commandType of REST, it offers a method field and if item two has a command type of SSH it offers a field of path and so on.
I found an answer.
Replace the [0] with [arrayIndex].
I found it from here: https://github.com/json-schema-form/angular-schema-form/commit/21f6d3ab64435b032456dfe19e03f96b29366320

ElasticSearch - Find matches with exact value

I'm new working with elastic search and I'm trying to make a simple query work. I'm using elasticseach 2.3. I can't use a newer version I'm limited by another technology I'm using.
Basically I have News stored in the database with a title, a source and a publication date.
The query I'm trying to make should search for all the news that contain a certain keyword, come from some sources A or B and have a publication date in the range given.
So far I have this:
{
"query":{
"bool":{
"must":[
{
"bool":{
"should":[
{
"match":{
"source":"SOURCE_A"
}
},
{
"match":{
"source":"SOURCE_B"
}
},
{
"match":{
"title": "keyword"
}
}
]
}
}
],
"filter":{
"range":{
"publication_date":{
"gte":"DATE_FROM",
"lte":"DATE_TO"
}
}
}
}
}
}
The problem is that if a given source starts exactly the same as another source (for example: "SOURCE" and "SOURCE ABC") they are both included in the result. I would like to match exactly the same source.
Can anyone point me in the right direction?
Thanks!
The index is being created by Django Haystack but given its limitations I need to query the database myself. The index mapping is the following:
{
"myindex": {
"mappings": {
"modelresult": {
"properties": {
"django_ct": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"django_id": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"id": {
"type": "string"
},
"publication_date": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"source": {
"type": "string",
"analyzer": "ascii_analyser"
},
"summary": {
"type": "string",
"analyzer": "ascii_analyser"
},
"text": {
"type": "string",
"analyzer": "ascii_analyser"
},
"title": {
"type": "string",
"analyzer": "ascii_analyser"
},
"url": {
"type": "string",
"analyzer": "ascii_analyser"
}
}
}
}
}
}

Country -> State-> City with angular-schema-form-dynamic-select

I am currently using angular-schema-form-dynamic-select and my requirement is to select states based on a country selected. I'm storing data in the db like this country -> state -> city. Can anyone Help me on this?
This is my form:
[
{
"key": "country",
"type": "strapselect",
"placeholder":"country",
"options": {
"httpGet": {
"url": "/countries"
},
"map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
}
},
{
"key": "state",
"type": "strapselect",
"placeholder":"state",
"options": {
"httpGet": {
"url": "/states"
},
"map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
}
},
{
"key": "city",
"type": "strapselect",
"placeholder":"city",
"options": {
"httpGet": {
"url": "/cities"
},
"map": { "valueProperty": "readonlyProperties.id", "nameProperty":"name" }
}
}
]
I think a feature like that would be indeed quite handy. Maybe you write something like this in the json string:
{
"type": "object",
"properties": {
"country": {
"type": "string",
"enumCallback": "getTitlesValues()"
}
}
}
And in your controller you would have that callback defined:
...
$scope.getTitlesValues = function () {
return ['India','Australia', 'Germany', 'Sweden']
}
...
I think a feature like that would be indeed quite handy.
Maybe you write something like this in the json string:
{
"type": "object",
"properties": {
"country": {
"type": "string",
"enumCallback": "getTitlesValues()"
}
}
}
And in your controller you would have that callback defined:
...
$scope.getTitlesValues = function () {
return ['India','Australia', 'Germany', 'Sweden']
}
...

Resources