I'm using Google's Api.ai and the Actions on Google console / SDK to create a simple Google Home app.
Currently stuck at the SDK init part:
Use Actions SDK to add actions to your Assistant app
$ gactions update --action_package PACKAGE_NAME --project orderpizza-dbe00
It automatically puts my project name after --project, however what is the PACKAGE_NAME?
The PACKAGE_NAME is the file name of your json file created by the
$ gactions init
So assuming you are using the default name the update would be:
$ gactions update --action_package action.json --project orderpizza-dbe00
Related
I have a google cloud run flask application named "HelloWorld1" already up and running however i need to create a second flask application. I followed the below steps as per documentation:
1- On "Cloud Shell Editor" clicked "<>Cloud Code" --> "New Application" --> "Cloud Run Application Basic Cloud Run Application .."-->"Python (Flask): Cloud Run", provide and new folder and application is created.
2- When i try to run it using "Run on Cloud Run Emulator" i get the following error:
Starting to run the app using configuration 'Cloud Run: Run/Debug Locally' from .vscode/launch.json...
To view more detailed logs, go to Output channel : "Cloud Run: Run/Debug Locally - Detailed"
Dependency check started
Dependency check succeeded
Starting minikube, this may take a while...................................
minikube successfully started
The minikube profile 'cloud-run-dev-internal' has been scheduled to stop automatically after exiting Cloud Code. To disable this on future deployments, set autoStop to false in your launch configuration /home/mian/newapp/.vscode/launch.json
Update initiated
Update failed with error code DEVINIT_REGISTER_BUILD_DEPS
listing files: file pattern [requirements.txt] must match at least one file
Skaffold exited with code 1.
Cleaning up...
Finished clean up.
I tried following:
1- tried to create different type of application e.g django instead of flask however always getting the same error
2- tried to give full path of [requirements.txt] in docker settings, no luck.
Please if someone help me understanding why i am not able to run a second cloud run Flask app due to this error?
It's likely that your Dockerfile references the 'requirements.txt' file, but that file is not in your local directory. So, it gives the error that it's missing:
listing files: file pattern [requirements.txt] must match at least one file
I am using python google app engine
could you tell me, how i can run python3 google app engine with ndb on local system?
Help me
https://cloud.google.com/appengine/docs/standard/python3
Please try this
Go to service account https://cloud.google.com/docs/authentication/getting-started
create json file
and add install this pip
$ pip install google-cloud-ndb
now open linux terminal
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
if window then open command prompt
set GOOGLE_APPLICATION_CREDENTIALS=C:\path\to\credentials.json
run this code in python3 in your terminal/command prompt
from google.cloud import ndb
client = ndb.Client()
with client.context():
contact1 = Contact(name="John Smith",
phone="555 617 8993",
email="john.smith#gmail.com")
contact1.put()
see this result in your datastore.. Google console
App Engine is a Serverless service provided by Google Cloud Platform where you can deploy your applications and configure Cloud resources like instances' CPU, memory, scaling method, etc. This will provide you the architecture to run your app.
This service is not meant to be used on local environments. Instead, it is a great option to host an application that (ideally) has been tested on local environments.
Let's say: You don't run a Django application with Datastore dependencies using App Engine locally, You run a Django application with Datastore (and other) dependencies locally and then deploy it to App Engine once it is ready.
Most GCP services have their Client libraries so we can interact with them via code, even on local environments. The ndb you asked belongs to the Google Cloud Datastore and can be installed in Python environments with:
pip install google-cloud-ndb
After installing it, you will be ready to interact with Datastore locally. Please find details about setting up credentials and code snippets in the Datastore Python Client Library reference.
Hope this is helpful! :)
You can simply create emulator instance of the datastore on your local:
gcloud beta emulators datastore start --project test --host-port "0.0.0.0:8002" --no-store-on-disk --consistency=1
And then use it in the code in main app file:
from google.cloud import ndb
def get_ndb_client(namespace):
if config.ENVIRONMENT != ENVIRONMENTS.LOCAL:
# production
db = ndb.Client(namespace=namespace)
else:
# localhost
import mock
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
db = ndb.Client(project="test", credentials=credentials, namespace=namespace)
return db
ndb_client = get_ndb_client("ns1")
Under Ubuntu environment, NodeJS Google Vision complains:
Error: Unable to detect a Project Id in the current environment.
Even though I already put json credential through
$ export GOOGLE_APPLICATION_CREDENTIALS=/var/credential_google.json"
Please help.
As a quick hack you can try this :
$ GOOGLE_APPLICATION_CREDENTIALS="/var/credential_google.json" node app.js
It's not recommended to use a .json config file locally. I've seen these leak on production servers causing whole platforms to be deleted + the introduce environmental switching and security issues.
Setup Google Cloud CLI.
Now the server will 'look' at the local environment and use that.
If you get the error "Unable to detect a Project Id in the current environment.", it means the auth library cannot find the project default id.
You need to have a base project in Google Cloud set, regardless of environmental variables and project you're running.
Run
gcloud config set project [some-project-id]
Now if you run (node example)
"dev": "NODE_ENV=dev GCP_PROJECT=some-project-id nodemon index.ts",
It will load the project environment. This also allows you to deploy easier with:
"deploy:dev": "y | gcloud app deploy --project some-dev-project app.yaml",
"deploy:prod": "y | gcloud app deploy --project some-prod-project app.yaml"
App engine has security setup automatically with standard environments. With flex you can use one of the manage images Google Provides.
If you are usually a windows user and trying out Ubuntu (like me), the problem is likely with the assumptions that the export command exports variable to all terminal sessions and that you need to open a new terminal to get it to use (as expected in a windows terminal for an environment variable).
The export command doesn't export the variable to another terminal session. So if you export it in a terminal, you use it on the same terminal.
If you would like to export it permanently, then you can try the solution listed here
You can put the path to the JSON credentials directly when instantiating the client, by passing it as an argument.
For example:
const client = new speech.SpeechClient( {keyFilename: "credential_google.json"});
Also, for me setting it in the terminal didn't work.
How to test the chatbots using botium or testmybot node packages?
I am not able to find any end to end sample to understand this.
There are several samples included in the Github repositories for Testmybot and Botium.
The Botium Wiki contains some useful information and a Walkthrough.
The basic steps for running a Botium script are as follows (from one of the samples)
Install requirements
Install Node.js
Install docker
Install docker-compose
There are other samples available which don't require docker.
Initialize Botium directory
Open a command line window, create a directory, initialize NPM and download Botium package.
mkdir botium
cd botium
npm init
npm install --save botium-core
Load botium library
First, load the botium library and required classes.
const BotDriver = require('botium-core').BotDriver
const Capabilities = require('botium-core').Capabilities
const Source = require('botium-core').Source
Configure capabilities
Tell Botium what kind of chatbot is under test and how to connect to it. In this sample, the chatbot should be loaded into a docker container and Botium has to hook into the Microsoft Bot Framework.
const driver = new BotDriver()
.setCapability(Capabilities.PROJECTNAME, 'core-CreateNewConversation')
.setCapability(Capabilities.CONTAINERMODE , 'docker')
.setCapability(Capabilities.BOTFRAMEWORK_API, true)
.setCapability(Capabilities.BOTFRAMEWORK_APP_ID, 'my microsoft app id')
.setCapability(Capabilities.BOTFRAMEWORK_CHANNEL_ID, 'facebook')
Configure chatbot repository
Botium retrieves the chatbot code directly from the source Github repository. As an alternative, the repository could be cloned first and loaded from a local directory. In a CI environment, loading from Git usually makes more sense.
Additionally, the command to initialize the Git repository ("npm install"), the command to start the chatbot service ("npm start") and some environment variables are required to run the sample chatbot.
driver.setSource(Source.GITURL, 'https://github.com/Microsoft/BotBuilder-Samples.git')
.setSource(Source.GITDIR, 'Node/core-CreateNewConversation')
.setSource(Source.GITPREPARECMD, 'npm install')
.setCapability(Capabilities.STARTCMD, 'npm start')
.setEnv('MICROSOFT_APP_ID', 'my microsoft app id')
.setEnv('MICROSOFT_APP_PASSWORD', 'my microsoft app password')
.setEnv('NODE_DEBUG', 'botbuilder')
.setEnv('DEBUG', '*')
Running a conversation and evaluate response
Botium provides a "fluent interface".
First, the Botium driver is initialized (work directory created, repository downloaded, docker network constructed, ...) and started.
driver.BuildFluent()
.Start()
...
Then, a conversation is started by sending input to the chatbot ("UserSaysText") or by waiting for a reaction from the chatbot ("WaitBotSaysText"). The conversation is tailored to the chatbot in use. In case chatbot doesn't react or shows unexpected reaction, the conversation is ended immediately.
...
.UserSaysText('hi bot')
.WaitBotSaysText((text) => assert('You\'ve been invited to a survey! It will start in a few seconds...', text))
.WaitBotSaysText(null, 10000, (text) => assert('Hello... What\'s your name?', text))
.UserSaysText('John')
.WaitBotSaysText((text) => assert('Hi John, How many years have you been coding?', text))
.UserSaysText('5')
.WaitBotSaysText((text) => assert('What language do you code Node using?', text))
.UserSaysText('CoffeeScript')
.WaitBotSaysText((text) => assert('Got it... John you\'ve been programming for 5 years and use CoffeeScript.', text))
...
In the end, Botium is stopped and some cleanup tasks are performed.
Don't forget the "Exec" call, otherwise nothing will be executed at all!
...
.Stop()
.Clean()
.Exec()
...
Run the program and watch output
Now run the program as usual in a command line window.
[ec2-user#ip-172-30-0-104 botframework]$ node botiumFluent.js
SUCCESS: Got Expected <You've been invited to a survey! It will start in a few seconds...>
SUCCESS: Got Expected <Hello... What's your name?>
SUCCESS: Got Expected <Hi John, How many years have you been coding?>
SUCCESS: Got Expected <What language do you code Node using?>
SUCCESS: Got Expected <Got it... John you've been programming for 5 years and use CoffeeScript.>
READY
[ec2-user#ip-172-30-0-104 botframework]$
TestMyBot
Botium is comparable to what Selenium/Appium are doing (unified API and "Page Object Model"). TestMyBot is a layer above Botium to integrate Botium with CI/CD pipelines and test runners like Mocha and Jasmine. The conversations don't have to be coded as above, but are "scripted" in text files, excel files or yml files, for example:
urvey
#me
hi
#bot
You've been invited to a survey! It will start in a few seconds...
#bot
Hello... What's your name?
#me
John
#bot
Hi John, How many years have you been coding?
#me
10
#bot
What language do you code Node using?
#me
C#
#bot
I didn't understand. Please choose an option from the list.
#me
JavaScript
#bot
Got it... John you've been programming for 10 years and use JavaScript.
All of these files have to be placed in the directory spec/convo, and the test cases for Jasmine or Mocha (or any other test runner) are created on-the-fly with just a short scriptlet (placed into spec/testmybot.spec.js):
const bot = require('testmybot');
bot.helper.jasmine().setupJasmineTestSuite(60000);
It really helps to have knowledge of Jasmine or Mocha. When correctly set up, the only command to run is:
npm run test
I'm trying to follow the tutorial noted below:
http://www.ibm.com/developerworks/cloud/library/cl-bluemix-nodejs-app/
But when I push my app, I see the following:
Using manifest file /mytests/bluemix-node-mysql-upload/manifest.yml
Updating app jea-node-mysql-upload in org jea68#gmail.com / space dev as jea68#gmail.com...
OK
Uploading jea-node-mysql-upload...
Uploading app files from: /mytests/bluemix-node-mysql-upload/app
Uploading 53.6K, 11 files
Done uploading
OK
FAILED
Could not find service mysql-database to bind to jea-node-mysql-upload
Is there a problem with the node.js buildpack or is the documentation faulty?
I've been able to push apps to Node.js without any problems this morning. The documentation assumes the user knows that the service has already been created. The manifest.yml included in the github repo of the tutorial defines a service (mysql-database) that has not been created. Run the following command to create the service:
$ cf create-service mysql 100 jea-mysql-node-upload-service
Then modify the manifest.yml to include:
services:
- jea-mysql-node-upload-service
Alternatively, since you already have an app, you can bind the application to the service by running the following:
$ cf bind-service jea-node-mysql-upload jea-mysql-node-upload-service
$ cf start jea-node-mysql-upload
It looks like a fault in the documentation. If you look at Step 2 part 3 it says to create the my-sql service using this command:
cf create-service mysql 100 mysql-node-upload
which will name the service instance as mysql-node-upload, however the manifest.yml file that you cloned from github contains the service name of just mysql-service. It is the manifest.yml file that links the app with the service instance.
The options are either the change the manifest.yml file to be the correct name of your mysql service instance or recreate the mysql service instance with the name that is in your manifest.yml.