I would like used the V2 API on my dialogflow fullfilment.
But when I self hosting an express, only v1 works, Why ?
With firebase functions both V1 and V2 works with the same code.
I apply this : https://developers.google.com/actions/reference/nodejs/lib-v1-migration,
Error for the welcome intent :
Request from simulator
{
"user": {
"userId": "ABwppHHtohp6Z0QsGp9X_TSwUK3gCxdRwCZ5w3kXR-iI-aXiUSNZR3Vuo59vocUIgP80gE2qWs2SFKk-fI6g83YJjA",
"locale": "fr-CA",
"lastSeen": "2019-02-25T15:29:15Z"
},
"conversation": {
"conversationId": "ABwppHHfpVWINKIQFvk-bzrVSvu4s-8JexXgZXP7FQ-NQ5HmPAneHtGY0u86_llCV--tj3TZpMtCMIMCZakyxc7mYQ",
"type": "NEW"
},
"inputs": [
{
"intent": "actions.intent.MAIN",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "Parler avec le diable"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
}
],
"requestType": "SIMULATOR"
}
reponse from simulator :
{
"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\":\"50104e9c-79ec-4545-a510-88ffd1944af7\",\"timestamp\":\"2019-02-25T15:32:35.568Z\",\"lang\":\"fr-ca\",\"result\":{},\"status\":{\"code\":206,\"errorType\":\"partial_content\",\"errorDetails\":\"Webhook call failed. Error: 400 Bad Request\"},\"sessionId\":\"ABwppHHfpVWINKIQFvk-bzrVSvu4s-8JexXgZXP7FQ-NQ5HmPAneHtGY0u86_llCV--tj3TZpMtCMIMCZakyxc7mYQ\"}"
}
]
}
}
}
Simulator :
Any idea ?
I found the issue. It was a wrong express configuration with bodyparser.
This is my code :
import express from 'express';
import { SERVER_NAME, ENTRY_POINT, PORT } from './constants';
import { app } from './app/app';
export const server = express();
server.set('port', PORT);
server.set('trust proxy', 'loopback');
server.use(express.json({}));
server.post(ENTRY_POINT, app);
server.get('/', (req, res) => {
res.send(SERVER_NAME);
});
just used express.use() instead body parser with express 4.16. It seems to me that it resolve the problem. Now V2 API with dialogflow seems works.
Related
Is anyone able to get "NO_INPUT" requests from AoG when once they've configured their action.json to route those requests to their server?
I'm receiving "actions.intent.CANCEL" intent requests, but not "actions.intent.NO_INPUT"
My action.json file...
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "thebigbadtest"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"talk to the Sophmora"
]
}
}
}
],
"conversations": {
"thebigbadtest": {
"name": "thebigbadtest",
"url": "https://api.oogum.io/rest/aog/agents/GYuM1j2At8eVLOqh8m1q/apprequests",
"inDialogIntents": [{
"name": "actions.intent.CANCEL"
}, {
"name": "actions.intent.NO_INPUT"
}]
}
},
"locale": "en"
}
I'm using loopback 3 to build a backend with mongoDB.
So i have 3 models: Object, Attachment and AwsS3.
Object has a relation Embeds2Many to Attachment.
Attachment has a relation Many2One to AwsS3.
Objects look like that in mongoDB
[
{
"fieldA": "valueA1",
"attachments": [
{
"id": 1,
"awsS3Id": "1234"
},
{
"id": 2,
"awsS3Id": "1235"
}
]
},
{
"fieldA": "valueA2",
"attachments": [
{
"id": 4,
"awsS3Id": "1236"
},
{
"id": 5,
"awsS3Id": "1237"
}
]
}
]
AwsS3 looks like that in mongoDB
[
{
"id": "1",
"url": "abc.com/1"
},
{
"id": "2",
"url": "abc.com/2"
}
]
The question is: how can i get Objects included Attachment and AwsS3.url over the RestAPI?
I have try with the include and scope filter. But it didn't work. It look like, that this function is not implemented in loopback3, right? Here is what i tried over the GET request:
{
"filter": {
"include": {
"relation": "Attachment",
"scope": {
"include": {
"relation": "awsS3",
}
}
}
}
}
With this request i only got the Objects with Attachments without anything from AwsS3.
UPDATE for the relation definitons
The relation from Object to Attachment:
"Attachment": {
"type": "embedsMany",
"model": "Attachment",
"property": "attachments",
"options": {
"validate": true,
"forceId": false
}
},
The relation from Attachment to AwsS3
in attachment.json
"relations": {
"awsS3": {
"type": "belongsTo",
"model": "AwsS3",
"foreignKey": ""
}
}
in AwsS3.json
"relations": {
"attachments": {
"type": "hasMany",
"model": "Attachment",
"foreignKey": ""
}
}
Try this filter:
{ "filter": { "include": ["awsS3", "attachments"]}}}}
Trying to implement NEW_SURFACE in webhook response (Google Assistant vocal calling Dialogflow calling a webhook).
When I have web browser capability I display my cards, but I when to redirect the user to his phone when he is from the Google Home.
This is my error in Action On google :
{
"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\":\"28ef98e1-caec-4e1f-9a14-8fda597e8a06\",\"timestamp\":\"2018-08-17T12:31:10.735Z\",\"lang\":\"fr-ca\",\"result\":{},\"alternateResult\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1534509012113\"}"
}
]
}
}
}
And this is my webhook response :
{
"fulfillmentMessages": [],
"payload": {
"google": {
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "TEST CHANGE SURFACE"
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.NEW_SURFACE",
"inputValueData": {
"#type": "type.googleapis.com/google.actions.v2.NewSurfaceValueSpec",
"context": "To show you an image",
"notificationTitle": "Check out this image",
"capabilities": [
"actions.capability.SCREEN_OUTPUT"
]
}
}
]
}
]
}
},
"source": "google"
}
Need help please ;-)
I want to enable account linking on an Google Assistant application using Actions Sdk.
I have already provided the information in the Account Linking section of the AoG Console :
The grant Type is Authorization code.
I use Auth0 as Oauth Server and i checked that the endpoints are functional.
When the application is invoked using the simulator, the server application send the following json response :
{
"expectUserResponse": true,
"finalResponse": null,
"expectedInputs": [{
"possibleIntents": [{
"intent": "actions.intent.SIGN_IN",
"inputValueData": null
}],
"inputPrompt": {
"richInitialPrompt": {
"items": [{
"simpleResponse": {
"textToSpeech": "Merci de vous authentifier",
"ssml": null,
"displayText": "Merci de vous authentifier"
}
}]
}
}
}],
"conversationToken": null,
"isInSandbox": false
}
I expected then to see the message like : it looks like your account … is not linked
Instead of that, the assistant immediately sends the following request to the server :
{
"user": {
"userId": "ABwppHGK6fClByrbLlS8WDM4xfY0qEck5i_kOGMhlJtuj64SjC-8qDqlH3xZ3BN7f9Yz1JDza-sc",
"locale": "fr-CA",
"lastSeen": "2018-04-23T14:12:02Z"
},
"conversation": {"conversationId": "1524493058716", "type": "NEW"},
"inputs": [{
"intent": "actions.intent.SIGN_IN",
"rawInputs": [{"inputType": "KEYBOARD"}],
"arguments": [{
"name": "SIGN_IN",
"extension": {
"#type": "type.googleapis.com/google.actions.v2.SignInValue",
"status": "ERROR"
}
}]
}],
"surface": {
"capabilities": [
{"name": "actions.capability.WEB_BROWSER"},
{"name": "actions.capability.MEDIA_RESPONSE_AUDIO"},
{"name": "actions.capability.SCREEN_OUTPUT"},
{"name": "actions.capability.AUDIO_OUTPUT"}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{"name": "actions.capability.SCREEN_OUTPUT"},
{"name": "actions.capability.AUDIO_OUTPUT"}
]
}
]
}
Did someone have the same problem ? Thanks
I have a working example, but it might be different of what you are doing because I ask the sign-in with dialogflow Integrations' tab for Google Assistant, and not explicitely with the SDK. The code is for the V2 of Dialogflow, I also have one for the V1 but it is now legacy.
This is my BONJOUR intent that is triggered when my app is launched:
const rp = require('request-promise');
app.intent('BONJOUR', (conv) => {
console.log("Debug: SAY_HELLO");
const accessToken = conv.user.access.token;
console.log("Access Token = "+accessToken);
//========Auth with OAuth website========
if (!accessToken) {
conv.ask(new SignIn());
} else {
let options = {
method: 'GET',
url: '[...]',//Oauth URL
headers:{
authorization: 'Bearer ' + accessToken,
}
};
// I use the RP lib as we need Promises for the V2 of Dialogflow.
return rp(options).then((body) => {
let data = JSON.parse(body);
console.log("auth data ="+JSON.stringify(data));
//You can access the auth data easily here
// For example if you want the name, it's in data.given_name, etc...
//Use conv.ask() to say something here
}).catch((error) => {
console.log("Error in auth request"+error);
})
}
});
Update:
This is my JSON mais the SignIn() is called, as I just tested it, it doesn't work (I created an intent that receives the actions_intent_SIGN_IN event from an example. And it never asks for sign In , I'm always in the else.)
Response {
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
},
"userStorage": "{\"data\":{}}",
"systemIntent": {
"intent": "actions.intent.SIGN_IN",
"data": {
"#type": "type.googleapis.com/google.actions.v2.SignInValueSpec"
}
}
}
},
"outputContexts": [
{
"name": [...],
"lifespanCount": 99,
"parameters": {
"data": "{}"
}
}
]
}
Then the request after that is:
Request {
"responseId": "5a711f0e-be66-4311-b776-2085e81e9bde",
"queryResult": {
"queryText": "actions_intent_SIGN_IN",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "..."
},
{
"name": ".../actions_intent_sign_in",
"parameters": {
"SIGN_IN": {
"#type": "type.googleapis.com/google.actions.v2.SignInValue",
"status": "ERROR"
}
}
},
{
"name": "...",
"lifespanCount": 98,
"parameters": {
"data": "{}"
}
},
{
"name": "..."
},
{
"name": "..."
},
{
"name": "..."
},
{
"name": "..."
}
],
"intent": {
"name": "...",
"displayName": "Get Signin"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {},
"languageCode": "fr-fr"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"inputs": [
{
"rawInputs": [
{
"inputType": "KEYBOARD"
}
],
"arguments": [
{
"extension": {
"#type": "type.googleapis.com/google.actions.v2.SignInValue",
"status": "ERROR"
},
"name": "SIGN_IN"
}
],
"intent": "actions.intent.SIGN_IN"
}
],
"user": {
"userStorage": "{\"data\":{}}",
"lastSeen": "2018-04-24T12:21:19Z",
"locale": "fr-FR",
"userId": "ABwppHHXrOc7N24RC5YS1dMvt7C-MbpzTb5TtzmufeIpGTCINVlReIMb8RKo4SGQMgBY7BUvO1qhn0B-"
},
"conversation": {
"conversationId": "1524572717282",
"type": "ACTIVE",
"conversationToken": "[\"_actions_on_google\"]"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
}
]
}
},
"session": "..."
}
I hope it can help you somehow.
I'm trying to do a post request for creating a server inthe openstack using REST API. i tried this code (followed in the Openstack documentation) but it won't work.
Can you help please?
{
"server": { "name":"auto-allocate-network",
"imageRef":"d84ddc27-7e79-4f5f-a4fb-f5fccda375c3",
"flavorRef":"583c710b-684b-4d05-a65c-eb69927212bd",
"availability_zone": "nova",
"network":"9f2989d3-c859-4ff5-ae0b-163e4562ea38"
}}
the URI is :
http://192.1.1.184:8774/v2.1/servers
try this code, it works for me:
{
"server": {
"name": "test-vm1",
"imageRef": "876d6dd5-06c7-43ea-8917-3f93ca074885",
"flavorRef": "1",
"max_count": 1,
"min_count": 1,
"networks": [
{
"uuid": "3b7f6755-46b1-4437-a164-5757bf0baedc"
}
],
"security_groups": [
{
"name": "default"
}
]
}
}
this solution from #node not work for me,
and this is my result :
{
"choices": [
{
"status": "SUPPORTED",
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.compute+json;version=2"
}
],
"id": "v2.0",
"links": [
{
"href": "http://rocky-controller.jcamp.net:8774/v2/v2.0/c0b89f614b5a457cb5acef8fe8c2b320/servers",
"rel": "self"
}
]
},
{
"status": "CURRENT",
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.compute+json;version=2.1"
}
],
"id": "v2.1",
"links": [
{
"href": "http://rocky-controller.jcamp.net:8774/v2.1/v2.0/c0b89f614b5a457cb5acef8fe8c2b320/servers",
"rel": "self"
}
]
}
]
}