I am trying to run sample code for Interactive Canvas in Dialogflow but it's giving me the error.
Followed the steps here: https://developers.google.com/actions/interactivecanvas/build/action
app.intent('welcome', (conv) => {
conv.ask('Welcome! Do you want me to change color or pause spinning?');
conv.ask(new ImmersiveResponse({
url: 'https://www.google.com',
}));
});
Here is the package.json file content:
{
"name": "canvas-sample-functions",
"description": "Actions on Google Immersive Canvas Sample Functions",
"license": "Apache-2.0",
"private": true,
"engines": {
"node": "8"
},
"dependencies": {
"actions-on-google": "^2.7.0-preview.2",
"firebase-admin": "~7.0.0",
"firebase-functions": "^2.2.0"
}
}
The error I am getting is "TypeError: ImmersiveResponse is not a constructor."
Any help would be appreciated.
Thanks
You are likely not using the preview version of the Actions on Google client library. The package.json dependency should be:
"actions-on-google": "preview",
You should be using your own web app for the canvas URL. In particular you need to ensure that the web app will work with the restrictions places on canvas web apps: https://developers.google.com/actions/interactivecanvas/build/web-app#restrictions
Related
I have a working discord bot, but I would like to compile it into a .exe file. How to do that?
I tried to use pkg and nexe, but both did not make it correctly. Nexe did not even start giving me some strange errors that I did not manage to fix after reading docs and some discussions on the Internet.
Error: https://github.com/nexe/nexe/releases/download/v3.3.3/windows-x64-14.8.0 is not available, create it using the --build flag and Error: vcbuild.bat nosign release x64 exited with code: 1.
The pkg worked better, I got and exe file, but it did not seem to work:
I have this code, where bot is my discord client.
bot.on('ready', () =>
{
console.log(bot.guilds.cache.toJSON());
bot.guilds.cache.forEach((gui) =>
{
console.log(gui.id + ' ' + gui.name + ' ' + gui.memberCount);
});
console.log('Bot started!');
});
It gives one server when I start it using node index.js, but does not give any if I execute the exe file created, though the bot becomes online.
My package.json looks like this:
{
"name": "sth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"pkg": {
"assets": [ "jsons/**/*", "config.json" ]
},
"bin": "index.js",
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.4.1"
}
}
What am I doing wrong? Why does the bot start, but does not seem to be able to do anything? What have I missed?
i don't know of an .exe file code you can use BUT you can use a .bat file and put it on desktop and create shortcuts or put it on shell:startup in that you will want to write this
#echo off
node "js file path"
Hi everyone I'm beginner in nodejs .I want to test some basic functionality in my code.I m using JEST testing framework.In the command prompt I used npm test I could not test my code it shows
npm ERR! Test failed. Can anyone solve this issue? Thanks in advance...
lib.test.js:
const lib=require('../lib.js');
describe('absolute',()=>{
it('It should return positive number if given number is positive',()=>{
const result=lib.absolute(1);
expect(result).toBe(1);
});
it('It should return positive number if given number is negative',()=>{
const result=lib.absolute(-1);
expect(result).toBe(1);
})
it('It should return zero if given number is zero',()=>{
const result=lib.absolute(0);
expect(result).toBe(1);
});
});
lib.js:
// Testing numbers
module.exports.absolute = function(number) {
if (number > 0) return number;
if (number < 0) return -number;
return 0;
}
package.json:
{
"name": "testing-demo",
"version": "1.0.0",
"description": "",
"main": "db.js",
"directories": {
"test": "tests"
},
"dependencies": {},
"devDependencies": {
"jest": "^22.2.2"
},
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC"
}
I'm guessing the error you are seeing is
SecurityError: localStorage is not available for opaque origins
The default test environment for Jest is a browser-like environment provided by jsdom, which is required for testing code like React applications that are designed to run in the browser.
If you are going to use jsdom as the test environment then you need to set testURL in the Jest configuration, otherwise you will get the error seen above.
If your code is designed to run on node and you don't need a browser-like environment then you can set your test environment to be node.
The easiest way to do that in your case is to pass it as a command line argument to jest in your package.json:
"scripts": {
"test": "jest --env=node"
},
I am developing a module that I try to make as generic as possible (let's say BaseModule), and I want to extend it to feet my current purposes in another module (let's say ChildModule).
So ChildModule begins with:
require('BaseModule');
So I added BaseModule as a dependency of ChildModule. But when I want to use both of them on my real project, I cannot install both of them. Installing BaseModule removes ChildModule, and installing ChildModule moves BaseModule, in a way it is unreachable in my code afterward.
Both the module are on a git repository only (ie not published yet).
What is funny is that mongoose is also a dependency of ChildModule, and I don't have this issue. So I think I forgot something in BaseModule, but I don't know what...
It is a bit similar to this issue NPM dependencies shared by dependencies, which is supposed to be fixed on my NPM version (5.6). This issue is also similar, but as I said before I don't think it is a bug.
Is there any way to have nested dependency? If no, what is the standard way to do this kind of extension?
Here are the different package.json:
BaseModule's package.json
{
"name": "BaseModule",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+ssh://.../BaseModule.git"
},
"bundledDependencies": false,
}
ChildModule:
{
"name": "ChildModule",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+ssh://.../ChildModule.git"
},
"bundledDependencies": false,
"dependencies": {
"mongoose": "^4.13.9",
"BaseModule": ".../BaseModule"
}
}
and the project itself:
{
"name": "Project",
"dependencies": {
"mongoose": "^4.13.9",
"ChildModule": ".../ChildModule",
"BaseModule": ".../BaseModule",
"andALotMore": "*"
}
}
... stands for the correct address of my repositories.
I'm recently updating my cloud functions to TypeScript after the talks on the FirebaseSummit of this year.
All my code looks quite cool, but I'm having some problems trying to recover the types of Firestore API, such QuerySnapshot , DocumentReference...
async function getEventsMadeByUser(userId: string): Promise<FirebaseFirestore.DocumentSnapshot[]> {
const eventsMadeByUserQuery = await instance.collection('PrivateUserData')
.doc(userId).collection(EVENTS)
.where('interactionUser', '==', userId).get();
return eventsMadeByUserQuery.docs;
}
Right now my IDE (WebStorm) is not getting the types for FirebaseFirestore. This is how my package.json looks:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "^5.4.3",
"firebase-functions": "^0.7.2"
},
"devDependencies": {
"#types/express": "^4.0.37",
"typescript": "^2.3.2"
},
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"deploy": "tsc && firebase deploy --only functions"
},
"main": "build/index.js",
"private": true
}
I have already tried to add #firebase-firestore and nothing, it's not working. What is the right dependency to achieve this?
I finally figured it out! The firebase-admin module is just a simple wrapper that initializes Firestore for you. To get the real Firestore, add "#google-cloud/firestore": "^0.9.0" to your package.json. You can admire those beautiful types here: https://github.com/googleapis/nodejs-firestore/blob/master/types/firestore.d.ts.
import { DocumentData } from '#firebase/firestore-types'
I figured out that you can get the types directly from firebase-admin without adding additional packages:
import { firestore } from 'firebase-admin'
const iAmConsumingDB = (db: firestore.Firestore) => {
// do something
}
const iAmConsumingADocumentReference = (reference: firestore.DocumentReference) => {
// do something
}
I'm not very well versed in nodejs, but I'm trying to install hubot and run it with the hipchat adapter but, I'm getting the following error, package.json below.
I've followed this tutorial, http://theprogrammingbutler.com/blog/archives/2011/10/28/hipchat-hubot-and-me/ and the official one in the hubot-hipchat repo, https://github.com/hipchat/hubot-hipchat - I even tried setting it up on heroku to no avail. I'd prefer to set it up on my ubuntu 12.04 ec2 instance though, but if someone has a surefire way to heroku it's no problem :) Any help is greatly appreciated!
I've set the following environment variables also.
HUBOT_HIPCHAT_JID=<Username>
HUBOT_HIPCHAT_NAME=<Room nickname>
HUBOT_HIPCHAT_PASSWORD=<Password you created for hubots user>
HUBOT_HIPCHAT_TOKEN=<Token from Group Admin and API>
Error:
Error: Argument error
at new JID (/home/ubuntu/falcbot/node_modules/hubot-hipchat/node_modules/node-xmpp/lib/xmpp/jid.js:30:15)
at new Connector (/home/ubuntu/falcbot/node_modules/hubot-hipchat/src/connector.coffee:64:31, <js>:42:13)
at HipChat.run (/home/ubuntu/falcbot/node_modules/hubot-hipchat/src/hipchat.coffee:48:5, <js>:68:19)
at Robot.run (/home/ubuntu/falcbot/node_modules/hubot/src/robot.coffee:389:5, <js>:351:27)
at Object.<anonymous> (/home/ubuntu/falcbot/node_modules/hubot/bin/hubot:124:8, <js>:141:11)
at Object.<anonymous> (/home/ubuntu/falcbot/node_modules/hubot/bin/hubot:5:1, <js>:144:4)
at Module._compile (module.js:456:26)
package.json
{
"name": "hosted-hubot",
"version": "2.6.3",
"author": "GitHub Inc.",
"keywords": [
"github",
"hubot",
"campfire",
"bot"
],
"description": "A simple helpful robot for your Company",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/github/hubot/raw/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "https://github.com/github/hubot.git"
},
"dependencies": {
"hubot": "2.6.3",
"hubot-scripts": "2.5.3",
"hubot-hipchat": "2.5.1-4",
"optparse": "1.0.4"
},
"engines": {
"node": ">= 0.8.x",
"npm": ">= 1.1.x"
}
}
Apparently I forgot to export the variables. I am now not getting any errors when starting hubot with -a hipchat