Unable to update the Knowledge in QnA maker - azure

Unable to update the Knowledge in QnA maker whereas i am able to add the data to my Knowledge Base.Below is my update related REQUEST object
references: https://github.com/Azure-Samples/cognitive-services-qnamaker-java/blob/master/update-knowledge-base.java
{
"update": {
"qnaList": [
{
"id": 0,
"answer": "[92 Newcastle Court Roanoke, VA 24012](https://www.google.com/)",
"questions": [
"Where is Virginia located",
"What is the address of Roanoke",
"Roanoke address",
"Roanoke location"
],
"metadata": [
{
"name": "fragmenttype",
"value": "location"
},
{
"name": "locationname",
"value": "Roanoke"
},
{
"name": "type",
"value": "locationinfo"
}
]
},
{
"id": 1,
"answer": "[880 Oakwood St.Billerica, MA 01821](https://www.google.com/)",
"questions": [
"Where is Billerica located",
"What is the address of Billerica",
"Billerica address",
"Billerica location"
],
"metadata": [
{
"name": "fragmenttype",
"value": "location"
},
{
"name": "locationname",
"value": "Billerica"
},
{
"name": "type",
"value": "locationinfo"
}
]
}
]
}
}
and error response is:
{
"error": {
"code": 12,
"message": "Parameter is null",
"target": null,
"details": null,
"innerError": null
}
}

Your API call should be as below format.
More information can be found here
"update": {
"name": "QnA Maker FAQ Prompts Bot",
"qnaList": [
{
"id": 2,
"answer": "You can use our REST apis to create a KB. See here for details: https://learn.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase/create",
"source": "Custom Editorial",
"questions": {
"add": [],
"delete": []
},
"metadata": {
"add": [],
"delete": []
}
}
]
}

Related

Properly Create a Device Template from a Live Device in Azure IOT Central

I have LoRaWAN IoT devices from the TTN network, which I have brought to Azure IoT Central. I would like to get specific data inside the JSON in order to make alert rules. Here is a sample of the JSON I receive from a Milesight PIR & Light Sensor. Suppose I only want to get the "battery", "daylight" and "pir" values to make the alert, how do I go about that?
{
"end_device_ids": {
"device_id": "eui-24e124538c195063",
"application_ids": {
"application_id": "test-1117"
},
"dev_eui": "24E124538C195063",
"join_eui": "24E124C0002A0001",
"dev_addr": "260D82F3"
},
"received_at": "2023-02-01T13:52:47.892042526Z",
"uplink_message": {
"session_key_id": "AYYLj9wg6AeehHWwDLrzLg==",
"f_port": 85,
"f_cnt": 38,
"frm_payload": "AXVkAwAABAAA",
"decoded_payload": {
"battery": 100,
"daylight": "dark",
"pir": "normal"
},
"rx_metadata": [
{
"gateway_ids": {
"gateway_id": "eui-24e124fffef5531c",
"eui": "24E124FFFEF5531C"
},
"time": "2023-02-01T13:52:47.429725885Z",
"timestamp": 2696081442,
"rssi": -64,
"channel_rssi": -64,
"snr": 13,
"uplink_token": "CiIKIAoUZXVpLTI0ZTEyNGZmZmVmNTUzMWMSCCThJP/+9VMcEKLgy4UKGgwIr93pngYQ94rGxQIg0Ino17uJFw==",
"received_at": "2023-02-01T13:52:47.596682842Z"
}
],
"settings": {
"data_rate": {
"lora": {
"bandwidth": 125000,
"spreading_factor": 7,
"coding_rate": "4/5"
}
},
"frequency": "867700000",
"timestamp": 2696081442,
"time": "2023-02-01T13:52:47.429725885Z"
},
"received_at": "2023-02-01T13:52:47.683989041Z",
"confirmed": true,
"consumed_airtime": "0.061696s",
"network_ids": {
"net_id": "000013",
"tenant_id": "ttn",
"cluster_id": "au1",
"cluster_address": "au1.cloud.thethings.network"
}
},
"_eventtype": "Telemetry",
"_timestamp": "2023-02-01T13:52:49.35Z"
}
I was able to get the values by uploading my own DTDL.
Once the device sends data to Azure IOT Central from TTN, the device will have no template.
I first created a template from the raw telemetry sent.
I went to the new device template created, clicked EDIT DTDL, then placed the following JSON:
{
"#id": "dtmi:telavi:eui24e124538c195063;1",
"#type": "Interface",
"contents": [
{
"#type": [
"Telemetry",
"DateTimeValue"
],
"displayName": {
"en": "received_at"
},
"name": "received_at",
"schema": "dateTime"
},
{
"#type": [
"Telemetry",
"NumberValue"
],
"description": {
"en": "battery"
},
"displayName": {
"en": "battery"
},
"name": "battery",
"schema": "integer"
},
{
"#type": [
"Telemetry",
"StringValue"
],
"description": {
"en": "daylight"
},
"displayName": {
"en": "daylight"
},
"name": "daylight",
"schema": "string"
},
{
"#type": [
"Telemetry",
"StringValue"
],
"description": {
"en": "pir"
},
"displayName": {
"en": "pir"
},
"name": "pir",
"schema": "string"
}
],
"displayName": {
"en": "eui-24e124538c195063"
},
"#context": [
"dtmi:iotcentral:context;2",
"dtmi:dtdl:context;2"
]
}

No operations defined in spec! && Resolver error Cannot read properties of undefined (reading 'api')

I have this error in my node JS in swagger-ui-express I don`t know how to fix it
enter image description here
this is the code in the index.js file
in this code I`am tryin to call the json file that I make and call it swagger.json
const swaggerUi = require('swagger-ui-express'), swaggerDocument = require('./swagger.json')
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
that the pic of the beggin of the code
enter image description here
but I`am think that the error is here in this json file
"paths": {
"/api/category": {
"tages": [
"Category"
],
"summery": [
"Get all Categories"
],
"parameters": [
{
"name": "categoryName",
"in": "query",
"required": false,
"description": "Category name",
"type": "string"
},
{
"name": "page",
"in": "query",
"required": false,
"description": "Page Number",
"type": "integer",
"default": 1
},
{
"name": "PageSize",
"in": "query",
"required": false,
"type": "integer",
"default": 10
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ServiceResponse"
}
}
}
},
"post": {
"tages": [
"Category"
],
"summery": "Create Category API",
"parameters": [
{
"name": "categoryName",
"in": "formDate",
"descripition": "Category Name",
"required": true,
"type": "string"
},
{
"name": "CategoryDescription",
"in": "formDate",
"descripition": "Category Description",
"type": "string"
},
{
"name": "Category Image",
"in": "formDate",
"descripition": "Category Image",
"type": "file"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ServiceResponse"
}
}
}
}
},
There are some typos and syntax errors:
The "/api/category" path is missing the "get": node that would wrap the GET operation definition. It should look like this:
"paths": {
"/api/category": {
"get": {
"tags": ...
"tages" should be "tags".
"summery": [...] should be replaced with:
"summary": "Get all Categories",
"in": "formDate" should be "in": "formData" ("a" at the end).
"descripition" should be "description".
Paste your OpenAPI JSON into https://editor.swagger.io - it will show all errors.

Bot Framework Composer does not seem to interpret "if" well in the schema

This schema is perfectly json-validated but does not work in Bot-Framework-Composer. To be exact, when "has" is "true" the "secondFace" object MUST be set, when "has" is "false" it must be absent.
The Bot Framework Composer validates correctly if "has" is true, while if "has" is "false" it continues to request to set the "secondFace" object. Is it a composer bug or is there anything to do, perhaps at the composer's form-UI level?
"hasSecondFace": {
"type": "object",
"title": "Has second face for comparison ?",
"additionaProperties": true,
"properties": {
"has": {
"type": "boolean",
"default": true,
"title": "Has Second Face",
"description": "If true ha second face else No"
},
"secondFace": {
"title": "Second face to be compared",
"additionalProperties": true,
"required": [
"type",
"param"
],
"oneOf": [
{
"type": "object",
"title": "From Storage",
"properties": {
"type": {
"const": "fromFile"
},
"param": {
"$ref": "schema:#/definitions/stringExpression",
"title": "Storage key",
"description": "key name of the blob"
}
}
},
{
"type": "object",
"title": "image stream",
"properties": {
"type": {
"const": "fromKey"
},
"param": {
"$ref": "schema:#/definitions/stringExpression",
"title": "Stream of second face",
"description": "Second face to compare"
}
}
}
]
}
},
"if": {
"properties": {
"has": { "const": true }
},
"required": [ "has" ]
},
"then": {
"required": [ "secondFace" ]
},
"else": {
"not": { "required": [ "secondFace" ] }
}
}
}

ALEXA - How to send slot ID in service request

I am creating custom Alexa skill, with custom slots. I have created predefined values for the slot and assigned an ID to each. During my tests I can see that in the service request there is no ID key-value pair:
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.xXxxxxXXXx-xxXX-xXXx-xXXX-xxxXXXXXXxxx",
"intent": {
"name": "HowToIntent",
"slots": {
"action": {
"name": "action",
"value": "clear cache"
}
}
},
Is there any possibility to pass slot ID in the request?
"languageModel": {
"types": [
{
"name": "action",
"values": [
{
"id": "1",
"name": {
"value": "clear cache",
"synonyms": [
"flush cache",
"clean cache"
]
}
},
{
"id": "2",
"name": {
"value": "perform reindex",
"synonyms": [
"reindex",
"do reindex"
]
}
},
{
"id": "3",
"name": {
"value": "create a product",
"synonyms": [
"add product",
"make product"
]
}
},
{
"id": "4",
"name": {
"value": "create a category",
"synonyms": [
"add category",
"make category"
]
}
}
]
},
{
"name": "element",
"values": [
{
"id": "1",
"name": {
"value": "category tree",
"synonyms": [
"category structure",
"categories"
]
}
},
{
"id": "2",
"name": {
"value": "simple product",
"synonyms": []
}
},
{
"id": "3",
"name": {
"value": "gift card",
"synonyms": []
}
}
]
}
],
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "HowToIntent",
"samples": [
"how to {action}"
],
"slots": [
{
"name": "action",
"type": "action"
}
]
},
{
"name": "WelcomeIntent",
"samples": [],
"slots": []
},
{
"name": "WhatIsIntent",
"samples": [
"what is {element}"
],
"slots": [
{
"name": "element",
"type": "element"
}
]
}
],
"invocationName": "my assistant"
}
}

How to determine the type of the platform in Dialogflow (API.AI)

How do to identify from which platform the message came?
I want to support different platforms like Telegram and Facebook Messenger, When my webhook receive a message, I want to reply according to the platform the message came form.
For example, if the message came from Telegram I want to return a text message but if the message came from messenger I want to return a card.
You have a property source in originalRequest object, see fulfillment docs here.
{
"lang": "en",
"status": {
"errorType": "success",
"code": 200
},
"timestamp": "2017-02-09T16:06:01.908Z",
"sessionId": "1486656220806",
"result": {
"parameters": {
"city": "Rome",
"name": "Ana"
},
"contexts": [],
"resolvedQuery": "my name is Ana and I live in Rome",
"source": "agent",
"score": 1.0,
"speech": "",
"fulfillment": {
"messages": [
{
"speech": "Hi Ana! Nice to meet you!",
"type": 0
}
],
"speech": "Hi Ana! Nice to meet you!"
},
"actionIncomplete": false,
"action": "greetings",
"metadata": {
"intentId": "9f41ef7c-82fa-42a7-9a30-49a93e2c14d0",
"webhookForSlotFillingUsed": "false",
"intentName": "greetings",
"webhookUsed": "true"
}
},
"id": "ab30d214-f4bb-4cdd-ae36-31caac7a6693",
"originalRequest": {
"source": "google",
"data": {
"inputs": [
{
"raw_inputs": [
{
"query": "my name is Ana and I live in Rome",
"input_type": 2
}
],
"intent": "assistant.intent.action.TEXT",
"arguments": [
{
"text_value": "my name is Ana and I live in Rome",
"raw_text": "my name is Ana and I live in Rome",
"name": "text"
}
]
}
],
"user": {
"user_id": "PuQndWs1OMjUYwVJMYqwJv0/KT8satJHAUQGiGPDQ7A="
},
"conversation": {
"conversation_id": "1486656220806",
"type": 2,
"conversation_token": "[]"
}
}
} }

Resources