Dialogflow Webhooks: What is a webhookStatus code 14 mean? - dialogflow-es

My Dialogflow project is not making proper webhook calls. I ran the curl command, given to you while testing, in command prompt.
curl -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer ya29.c.Ko8BvQcQFJJgEzKprtZn9kWStTWE5trMyYN8_oilT_4LInyASeCGiBcrrSepTvrjomVCZKSaFF_RaCYoC_yBU0LWM8ODzRlliAHQv1C97veQuxNjq_aeWLEN361drz6Rk_WEn7hl52DRN32ee4xmV97rW8nqBVFsbPykXdkjj83iKWjwKv9FKVhNJNOfMaejMH4" -d "{\"queryInput\":{\"text\":{\"text\":\"run\",\"languageCode\":\"en\"}},\"queryParams\":{\"timeZone\":\"America/New_York\"}}" "https://dialogflow.googleapis.com/v2/projects/weathersample-ifjqjr/agent/sessions/ed2ec645-d8da-55b7-f71e-d0ee8d7ff2bb:detectIntent"
The response I got back was:
{
"responseId": "5eea8256-8771-4db1-8b51-2c82e31c7bf4-2e39b744",
"queryResult": {
"queryText": "run",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Error: Speed test has not been called properly",
"fulfillmentMessages": [
{
"text": {
"text": [
"Error: Speed test has not been called properly"
]
}
}
],
"outputContexts": [
{
"name": "projects/weathersample-ifjqjr/agent/sessions/ed2ec645-d8da-55b7-f71e-d0ee8d7ff2bb/contexts/location",
"lifespanCount": 5
},
{
"name": "projects/weathersample-ifjqjr/agent/sessions/ed2ec645-d8da-55b7-f71e-d0ee8d7ff2bb/contexts/weathercontext-followup",
"lifespanCount": 2
}
],
"intent": {
"name": "projects/weathersample-ifjqjr/agent/intents/98199125-8fc6-466f-98b6-7648e14b06e7",
"displayName": "runSpeedTest"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 2439
},
"languageCode": "en"
},
"webhookStatus": {
"code": 14,
"message": "Webhook call failed. Error: UNAVAILABLE."
}
At the bottom of this response there is a "webhookStatus" object with an unavailable error and code of 14. Does anyone know what that code means?

Webhook is basically HTTP callback which will be triggered when the web-hook enabled intents are matched. Code:14 UNAVAILABLE means that it is looking for a handling function mapped to "runSpeedTest" intent which is not present in the web-hook provided. You can test it in Fulfilment->Inline Editor before deploying it externally.

Related

How to send email with attachment using cURL with Azure Logic App

I am trying to build a simple Logic App in Azure, that sends an email with a zip attachment using cURL from a Linux VM.
In the Logic App, without the attachment it is working fine.
But it breaks once Attachment is configured.
JSON schema, When a HTTP request is received:
{
"properties": {
"Attachments": {
"type": "array"
},
"cc": {
"type": "string"
},
"from": {
"type": "string"
},
"html": {
"type": "string"
},
"subject": {
"type": "string"
},
"to": {
"type": "string"
}
},
"type": "object"
}
Config for Outlook Send an email v2, Logic App, Azure
Commands to send email from Linux VM:
# create attachment
echo "abcd" > test.txt
zip test.zip test.txt
# curl to send json to azure logic app, with attachment
curl -vvv --request POST \
--header 'Content-Type: application/json' \
--url 'https://prod-21.southeastasia.logic.azure.com:443/workflows/xxx/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xxx' \
--data '{"from": "xxx#outlook.com", "cc": "xxx#outlook.com, "Attachments": [{ "Content-Type": "BASE64_ENCODED_CONTENT", "Name": "test.zip" }], "to": "xxx#outlook.com", "subject": "Hello, World!", "html": "Hey, test email." }'
Error message from the Run History, Logic App, Azure
Full error from the log:
{
"status": 400,
"message": "Parameter 'Attachment Content' cannot be null or empty.\r\nclientRequestId: 40d2dc9c-549b-4608-xxxxxxxxxxxxxxx",
"error": {
"message": "Parameter 'Attachment Content' cannot be null or empty."
},
"source": "office365-sea.azconn-sea.p.azurewebsites.net"
}
Would like to know how to handle the attachment on this scenario. Any documentation would be helpful as well.
Thank you.
Would be also interested in this topic!
Did you try to use --form instead of --data? Or do you already have a solution for this?
I also tried to specify the "Attachments" property in logic apps as:
"properties": {
"Attachment": {
"contentEncoding": "base64",
"contentMediaType": "image/png",
"type": "string"
},
}
...

Azure REST API for running builds or pipelines

I am trying to automate the creation of Azure Pipelines for a particular branch using their REST api.
However, I am struggling to use almost all their API's, as their documentation lacks examples.
Things like List and Get are simple enough.
However, when it comes to queuing a build:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.0
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=6.0
{
"parameters": <parameters>, // how do i send paramters
"definition": {
"id": 1
},
"sourceBranch": "refs/heads/feature/my-pipeline",
"sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}
I am currently struggling to send parameters.
I have tried:
Simple JSON like:
"parameters": {
"appId": "bab",
"platform": "android",
"isDemo": true
}
and stringify version of JSON like:
"parameters": "{\"appId\": \"bab\",\"platform\": \"android\",\"isDemo\": true}"
but none seems to work.
It keeps giving me the error:
{
"$id": "1",
"customProperties": {
"ValidationResults": [
{
"result": "error",
"message": "A value for the 'appId' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'platform' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'isDemo' parameter must be provided."
}
]
},
"innerException": null,
"message": "Could not queue the build because there were validation errors or warnings.",
"typeName": "Microsoft.TeamFoundation.Build.WebApi.BuildRequestValidationFailedException, Microsoft.TeamFoundation.Build2.WebApi",
"typeKey": "BuildRequestValidationFailedException",
"errorCode": 0,
"eventId": 3000
}
The docs is very unclear in how to send this data: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.1#propertiescollection
Thank you very much for you help.
I believe you cannot pass runtime parameters trough the Queue API. Instead, use Runs API
With that, your request body (use Content-type: application/json) should look something similar to this:
{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/feature/my-pipeline"
}
}
},
"templateParameters": {
"appId": "bab"
"platform": "android"
"isDemo": true
}
}
I just realized that in the api-version=6.0 you can also send templateParameters on the Queue Service:
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?sourceBuildId={BUILD_BUILDID}&api-version=6.0
{
"templateParameters": { "doReleaseBuild": "True" },
"definition": {
"id": 1
},
"sourceBranch": "refs/heads/feature/my-pipeline",
"sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}

How to send to Amazon's Alexa Event Gateway?

I am trying to test sending an event to the Amazon's Event Gateway for my Alexa Smart Home skill using Postman but I keep receiving an 'invalid access token exception.' I have read the Amazon's documentation on this but apparently I am missing something.
When I enable my skill, my Smart Home Lambda receives the AcceptGrant.
{
"directive": {
"header": {
"namespace": "Alexa.Authorization",
"name": "AcceptGrant",
"messageId": "b2862179-bc56-4bb2-ac05-ce55c7a3e977",
"payloadVersion": "3"
},
"payload": {
"grant": {
"type": "OAuth2.AuthorizationCode",
"code": "ANSVjPzpTDBsdfoRSyrs"
},
"grantee": {
"type": "BearerToken",
"token": "Atza|IwEB..."
}
}
}
}
My lambda sends a POST to 'https://api.amazon.com/auth/o2/token' to receive the Access and Refresh tokens. It then stores those tokens. Next, my Lamdba responds with the following:
{
"event": {
"header": {
"namespace": "Alexa.Authorization",
"name": "AcceptGrant.Response",
"messageId": "b2862179-bc56-4bb2-ac05-ce55c7a3e977",
"payloadVersion": "3"
},
"payload": {}
}
}
I then get a message web page that I have successfully linked my skill - all is good.
Next, I try to send an event to Amazon's Alexa event gateway using the Postman app. I put the Access token (I also tried the Refresh token) in the header as a 'BearerToken' type and the in the 'scope' of the 'endpoint' object.
POST https://api.amazonalexa.com/v3/events?Content-Type=application/json&charset=UTF-8
with a header that specifies a Bearer Token (Access token received earlier) and a body that contains the following:
{
"event": {
"header": {
"messageId": "abc-123-def-456",
"namespace": "Alexa",
"name": "ChangeReport",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<access token>"
},
"endpointId": "MySmartSwitch-001"
},
"payload": {
"change": {
"cause": {
"type": "RULE_TRIGGER"
},
"properties": [
{
"namespace": "Alexa.ModeController",
"name": "mode",
"value": "Backup",
"timeOfSample": "2020-01-02T09:30:00ZZ",
"uncertaintyInMilliseconds": 50
}
]
}
}
},
"context": {
"properties": [
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2020-01-02T09:30:00Z",
"uncertaintyInMilliseconds": 60000
},
{
"namespace": "Alexa.EndpointHealth",
"name": "connectivity",
"value": {
"value": "OK"
},
"timeOfSample": "2020-01-02T09:30:00Z",
"uncertaintyInMilliseconds": 0
}
]
}
}
The response received is '401 Unauthorized'
{
"header": {
"namespace": "System",
"name": "Exception",
"messageId": "95bd23c3-76e6-472b-9c6d-74d436e1eb61"
},
"payload": {
"code": "INVALID_ACCESS_TOKEN_EXCEPTION",
"description": "Access token is not valid."
}
}
I figured out the issue. I was mistakenly sending parameters: Content-Type=application/json and charset=UTF-8 as well including them in the header - my bad. You just need to include them in the header.

DialogFlow Webhook works in DF but not Google Assistant Simulator

I've resorted to returning a default response in order to try to get this to work. This is hosted on AWS Lambda with an API Gateway. Last night I had some different code working, but now I can't seem to get anything to work through Google Assistant.
Here's the example V2 response I am using:
callback(null, {
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Choose a item"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"listSelect": {
"title": "Hello",
"items": [
{
"optionInfo": {
"key": "first title key"
},
"description": "first description",
"image": {
"url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"accessibilityText": "first alt"
},
"title": "first title"
},
{
"optionInfo": {
"key": "second"
},
"description": "second description",
"image": {
"url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
"accessibilityText": "second alt"
},
"title": "second title"
}
]
}
}
}
}
}
});
Here's the log output from Google Assistant to DialogFlow:
Received response from agent with body: HTTP/1.1 200 OK Server: nginx/1.13.6 Date: Sat, 11 May 2019 18:44:24 GMT Content-Type: application/json;charset=UTF-8 Content-Length: 772 X-Cloud-Trace-Context: e62f0526a5238882dd1c1a3b3a70e3b5/11459115340038791606;o=0 Google-Actions-API-Version: 2 Assistant-Interaction-Error-Code: -1 Assistant-Interaction-Error-Message: Failed to parse Dialogflow response into AppResponse because of empty speech response X-SHARD: default Via: 1.1 google Alt-Svc: clear
{
"responseMetadata": {
"status": {
"code": 10,
"message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
"details": [
{
"#type": "type.googleapis.com/google.protobuf.Value",
"value": "{\"id\":\"99120b53-f0a7-415f-b44e-73c7525fcd43\",\"timestamp\":\"2019-05-11T18:44:24.422Z\",\"lang\":\"en-us\",\"result\":{},\"alternateResult\":{},\"status\":{\"code\":206,\"errorType\":\"partial_content\",\"errorDetails\":\"Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: errorMessage in message google.cloud.dialogflow.v2.WebhookResponse.\"},\"sessionId\":\"ABwppHHok5GTHl8A6XWq9q-Yp1chkoZ4vT688i4HTxVgVQDcY1zHH2JUqVeCMPc_6bbA7WFf1e-nw0ZQxQ\"}"
}
]
}
}
}
I'm not sure where to go from here...Everything seems to be working correctly, I just can't figure out where the parser error is with Google Assistant. What gives?
Thanks.

swagger node ValidationError: "body" is required

I asked another question in another thread that gave me start on Swagger POST, but here I am stuck with another problem.
Here is my parameter definitions in my config json file
"/people/postTest": {
"post": {
"summary": "post test.",
"description": "Test.",
"operationId": "postTest",
"consumes": [
"application/json"
],
"tags": [
"test post"
],
"parameters": [
{
"in":"body",
"name":"body",
"description": "body for the POST request",
"required":true,
"schema": {"$ref":"#/definitions/inBody"}
}
] }}
"definitions": {
"inBody": {
"properties": {
"RequestSystem": {
"type": "string"
}}}}
(copied it from a big file so only took a small part but there is no issues with syntax)
and I am using CURL to post my request
curl -H "Content-Type: application/json" -X POST -d '{"RequestSystem":"IVR"}' http://localhost:8016/people/postTest
and this is the validation error I am getting when I try to start my node server
**ValidationError: "body" is required**
I know I am passing "RequestSystem" parameter but I am not sure where I am making mistakes in setting up my params in my config json file's "parameters". Any help would be appreciated.
I think you need to make required=false
[
{
"in":"body",
"name":"body",
"description": "body for the POST request",
"required":false,
"schema": {"$ref":"#/definitions/inBody"}
}
]
}
}
Try this It should work.

Resources