actions-on-google / assistant-actions-nodejs Goto Github PK
View Code? Open in Web Editor NEWNode.js Actions API Client Library
License: Apache License 2.0
Node.js Actions API Client Library
License: Apache License 2.0
As I see there are some bugs in readme
1, reviewSettings -> previewSettings
async function writePreviewFromDraft(projectId = 'your-project-id') {
// Create request payload
const request = {
parent: `projects/${projectId}`,
reviewSettings: {sandbox: {value: true}},
see:
interface IWritePreviewRequest {
/** WritePreviewRequest parent */
parent?: (string|null);
/** WritePreviewRequest previewSettings */
previewSettings?: (google.actions.sdk.v2.WritePreviewRequest.IPreviewSettings|null);
2, parent -> project (just in sendIteraction, in writePreview is it parent)
async function sendInteraction(projectId = 'your-project-id', queryText = 'example query text') {
const request = {
parent: `projects/${projectId}`,
input: {query: queryText}
};
see:
interface ISendInteractionRequest {
/** SendInteractionRequest project */
project?: (string|null);
3 So i use this payload for sendInteraction
const request = {
// parent: `projects/${projectId}`,
project: `projects/${projectId}`,
input: {
type: 'VOICE',
query: 'Parler avec audiobooks'
},
deviceProperties: {
surface: 'SMART_DISPLAY',
location: {
coordinates: {
latitude: -90.0,
longitude: -90.0
},
formattedAddress: '1600 Amphitheatre Pkwy, Mountain View, CA 94043',
zipCode: '94043',
city: 'Mountain View'
},
locale: 'en',
timeZone: 'America/New_York'
}
}
but got
{"code":3,"details":"Interaction did not trigger the preview of an action.","metadata":{"internalRepr":{},"options":{}}}
And I call the writePreviewFromDraft before. What can be the problem?
Hey,
i'm wondering how to start a conversation?
here's my code
const { GoogleAuth } = require('google-auth-library')
const auth = new GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/actions.builder']
})
auth.getClient().then(async client => {
client.request({
url: `https://actions.googleapis.com/v2/projects/${client.projectId}:sendInteraction`,
method: 'POST',
data: {
input: {
query: 'Talk to Super Test App',
type: 'KEYBOARD'
},
deviceProperties: {
surface: 'SMART_DISPLAY',
location: {
coordinates: {
latitude: -90.0,
longitude: -90.0
},
formattedAddress: '1600 Amphitheatre Pkwy, Mountain View, CA 94043',
zipCode: '94043',
city: 'Mountain View',
},
locale: 'en',
timeZone: 'America/New_York'
}
}
})
.then(console.log)
.catch(console.error)
})
Error
400
{
message: 'Interaction did not trigger the preview of an action.',
domain: 'global',
reason: 'badRequest'
}
Sample code
const {ActionsSdkClient} = require('@assistant/actions')
const client = new ActionsSdkClient({
parent: 'projects/action-builder-test-40291'
})
client.listVersions({parent: 'projects/action-builder-test-40291'}).then(version => console.log)
Log
mish@ushakov action-builder-test % node index.js
(node:39636) UnhandledPromiseRejectionWarning: Error: 9 FAILED_PRECONDITION: Firebase Terms of Service is not accepted. Navigate to your project's overview page on the Actions Console to accept the Terms of Service.
at Object.callErrorFromStatus (/Users/mish/Downloads/action-builder-test/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
at Object.onReceiveStatus (/Users/mish/Downloads/action-builder-test/node_modules/@grpc/grpc-js/build/src/client.js:176:52)
at Object.onReceiveStatus (/Users/mish/Downloads/action-builder-test/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
at Object.onReceiveStatus (/Users/mish/Downloads/action-builder-test/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
at /Users/mish/Downloads/action-builder-test/node_modules/@grpc/grpc-js/build/src/call-stream.js:145:78
at processTicksAndRejections (internal/process/task_queues.js:75:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:39636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:39636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
don't see anything on the overview page, adblocker disabled
It does not work for me. I got an error
{
"code":3,
"details":"Request contains an invalid argument.",
"metadata":{
"internalRepr":{},
"options":{}
}
}
My code is:
const { ActionsTestingClient } = require('@assistant/actions')
async function sendInteraction (projectId, queryText = 'example query text') {
const request = {
project: projectId,
parent: `projects/${projectId}`,
input: { query: queryText }
}
// Create client
const actionsTestingClient = new ActionsTestingClient({
credentials: {
client_email: 'xxx',
private_key: 'yyy'
}
})
const res = await actionsTestingClient.sendInteraction(request)
return res[0]
}
sendInteraction('xxx').then(res => {
console.log(`res ===> ${JSON.stringify(res)}`)
}).catch(err => {
console.log(err)
console.log(`err ===> ${JSON.stringify(err)}`)
})
is there any way to initialise ActionsSdkClient like this?.
const actionsSdkClient = new ActionsSdkClient({access_token:"##########################"});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.