Watson conversation service validation - ibm-watson

Is there any way of validating the user input which uses context variable?
My context variable stores the email address,so I would like the validation to check for the "#" sign.
Is there any way of doing this?

You can use the context variable with regex to extract the e-mail address, and after your code just validate the information, if the variableEmail = context.mail, do it... I cant help you with the code because you did not report your Programmation language.
But, if you want to saves the mail address in a context variable.
I made a conversation example so you know how to do it, here are the steps:
Part I:
Part II:
Part III:
The JSON files
Name example:
{
"context": {
"name": "<? input.text?>"
},
"output": {
"text": {
"values": [
"Hi $name, please report your e-mail address."
],
"selection_policy": "sequential"
}
}
}
Mail example:
{
"context": {
"mail": "<? input.text.extract('[a-zA-Z0-9._%+-]+#[a-zA-Z0-9.-]+(\\.[a-zA-Z]+){1,}',0) ?>"
},
"output": {
"text": {
"values": [
"Thanks very much, your name is $name and your mail is $mail."
],
"selection_policy": "sequential"
}
}
}
And finnaly, the result is:
If you want knows how to validate mail, search with the programming language you are developing the application and don't forget: the informations is saved inside: context.name or context.mail, according to my example.

Related

How does Google Smart Home determine channelNumber for action.devices.commands.selectChannel?

Created Google Smart Home Action.
Implemented device with:
a. deviceType = action.devices.types.SETTOP
b. deviceTrait = action.devices.traits.Channel
Device is successfully discovered and added to Google Home App's Homegraph.
User sends command: "Ok Google, change to ESPN"
Receives the following json in fulfillment URL:
{
"requestId": "[RequestId GUID]",
"inputs": [{
"intent": "action.devices.EXECUTE",
"payload": {
"commands": [{
"devices": [{
"id": "[SettopBox device Id]"
}],
"execution": [{
"command": "action.devices.commands.selectChannel",
"params": {
"channelCode": "espn",
"channelName": "ESPN",
"channelNumber": "206"
}
}]
}]
}
}]
}
Questions:
How does Google Smart Home determine the "channelNumber" value for "ESPN"? The user's command was "Ok Google, change to "ESPN". This does not contain any information about the channel number.
If a provider was set automatically, is there a setting in Google Home or Google Assistant to change this provider?
The number of a channel for the Channel trait is provided in the SYNC request along with any relevant labels.
{
"availableChannels": [
{
"key": "ktvu2",
"names": [
"Fox",
"KTVU"
],
"number": "2"
},
{
"key": "abc1",
"names": [
"ABC",
"ABC East"
],
"number": "4-11"
}
]
}
As shown in the snippet, the channel number comes from the service. This may be up to the developer of the integration how these numbers may be determined, whether from a cable provider or over-the-air. The field is optional, so a service without channel numbers may still work by saying its name.

Microsoft Azure Search

I have a use case in which:
I want to store images in Microsoft Blob storage,
Search images by giving text input like 'water' then all images which contain water in any way should appear in the search result.
I followed below link:
https://github.com/Azure/LearnAI-Cognitive-Search/blob/master/05-Lab-2-Image-Skills.md
But here I get to know that there are only 2 predefined skills which are ImageAnalysisSkill and OcrSkill which do not give full images as the search result.
Please help...
Programatically, you can use the Image Analysis Cognitive Skill to automatically extract tags from the images.
See https://learn.microsoft.com/en-us/azure/search/cognitive-search-skill-image-analysis for more information on this skill.
Your skill would look something like this:
{ "#odata.type": "#Microsoft.Skills.Vision.ImageAnalysisSkill",
"context": "/document/normalized_images/*",
"visualFeatures": [
"Tags",
"Description"
],
"defaultLanguageCode": "en",
"inputs": [
{
"name": "image",
"source": "/document/normalized_images/*"
}
],
"outputs": [
{
"name": "tags",
"targetName": "myTags"
},
{
"name": "description",
"targetName": "myDescription"
}
]
}
Then in the index, make sure to create a field of type Collection(Edm.String) to contain the list of tags. Let's call that the imageTags field. Make sure that field is searchable.
In the output field mappings (a property of the indexer) you will need to map the list of tags to the newly created imageTags field as follows:
"outputFieldMappings": [
{
"sourceFieldName": "/document/normalized_images/*/myDescription/tags/*",
"targetFieldName": "imageTags"
}
This will ensure that each of the tags found on the images are insterted in the imageTags array.
Please also read this document that explains how to extract normalized_imagesif you are not familiar with that already: https://learn.microsoft.com/en-us/azure/search/cognitive-search-concept-image-scenarios

JSON schema deeper object uniqueness

I'm trying to get into JSON schema definitions and wanted to find out, how to achieve a deeper object uniqueness in the schema definition. Please look at the following example definition, in this case a simple IO of a module.
{
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"required": ["modulIOs"],
"properties": {
"modulIOs": {
"type": "array",
"uniqueItems": true,
"items": {
"allOf": [
{
"type": "object",
"required": ["ioPosition","ioType","ioFunction"],
"additionalProperties": false,
"properties": {
"ioPosition": {
"type": "integer"
},
"ioType": {
"type":"string",
"enum": ["in","out"]
},
"ioFunction": {
"type":"string"
}
}
}
]
}
}
}
}
When I validate the following with i.E. draft-06 I get a positive validation.
{"modulIOs":
[
{
"ioPosition":1,
"ioType":"in",
"ioFunction":"240 V AC in"
},
{
"ioPosition":1,
"ioType":"in",
"ioFunction":"24 V DC in"
}
]
}
I'm aware that the validation is successfull because the validator does what he's intended to - it checks the structure of a JSON-object, but is there a possibility to validate object value data in deeper objects or do i need to perform the check elsewhere?
This is not currently possible with JSON Schema (at draft-7).
There is an issue raised on the official spec repo github for this: https://github.com/json-schema-org/json-schema-spec/issues/538
If you (or anyone reading this) really wants this, please thumbsup the first issue comment.
It's currently unlikely to make it into the next draft, and even if it did, time to impleemntations picking it up may be slow.
You'll need to do this validation after your JSON Schema validation process.
You can validate data value of your object fields by using JSON schema validation.
For example, if you need to check if ioPosition is between 0 and 100 you can use:
"ioPosition": {
"type": "integer",
"minimum": 0,
"maximum": 100
}
If you need to validate ioFunction field you can use regualr expression such as:
"ioFunction": {
"type": "string",
"pattern": "^[0-9]+ V [A,D]C"
}
Take a look at json-schema-validation.

Discord Webhooks and JSON construct limits for non-OAuth apps

I'm trying to clarify whether or not it's possible to POST JSON to a Discord channel webhook, without requiring a fully fledged OAuth authenticated app, and have it display more than a single line of text.
I can successfully send data to the webhook endpoint (using PowerShell), but it will ignore any fields other than 'content'. I was hoping to be able to post an Embed object, which comes from the Execute Webhook documentation, but it just seems to ignore it.
The JSON is like so:
{
"content": "Hi. I'm a robot.",
"embed": {
"title":"This is a title",
"type":"Rich",
"description":"This is a description",
"url":"http://www.google.com",
"fields": [
{
"name":"field1",
"value": "some value",
"inline": "true"
},
{
"name":"field2",
"value": "another value",
"inline": "true"
}
]
}
}
Thank you.

Watson conversation list entity value

In Watson Conversation when I create a dialog, can I list the values of my Entity?? for sample I have one entity fruits (apple, orange, and etc) so in one of my responses can I list the content of #fruits??
tks
For access intents and entities, first, your user need to request something for calling this objects... And in this case, your application will access:
Name of entity (#fruits);
The value of your entity typed from your user
Your app will show Fruit:orange if you user type orange, and Watson will recognize the entity and the value and save inside entities.fruit[0], not all values from your entity inside #fruits, like this.
Access entity: IBM Official Documentation.
Anyway: I think you want all values. Right?
I guess that best form is using context variables to save all "fruits" and show like:
For this Dialog runtime context:
{
"context": {
"toppings_array": ["orange", "apple"]
}
}
Update:
{
"context": {
"toppings_array": "<? $toppings_array.append('banana', 'melon') ?>"
}
}
Result:
{
"context": {
"toppings_array": ["orange", "apple", "banana", "melon"]
}
}
Show for the user:
{
"output": {
"text": "This is the array: <? $toppings_array.join(', ') ?>"
}
}
All JSON Example:
{
"context": {
"fruits": [
"lemon",
"orange",
"apple"
]
},
"output": {
"text": {
"values": [
"This is the array: <? $fruits.join(', ') ?>"
],
"selection_policy": "sequential"
}
}
}
Result:
This is the array: lemon, orange, apple
See the official example from Official Documentation.

Resources