Updating List of Entity Entries of DialogFlow Agent via API - javascript

Have been looking for a way to programmatically update our agent's entity entries for a certain entity type through the DialogFlow API. The purpose is to automate the updating of our entity entries on a scheduled basis (as our entries will be changing daily).
Came across this documentation page by Google on batch updating entity entries but have not been able to get anything better than a 404 when testing.
Have tried sending POST's via Postman using the supplied path and inserting my project name in URL but I believe I may be making naive mistakes as I am new to this area (specifically REST-stuff)
Below is an example of the current 404 response & path used.
We are just looking to get past the 404 error, once we have the contact setup, should be able to figure out auth & the rest.

There are several things you need to take into account.
The URL should look like this:
https://dialogflow.googleapis.com/v2/projects/julia-development-2/agent/entityTypes/actual_id/entities:batchUpdate
the "parent" you used in the URL is just the name of the path param
make sure "julia-development-2" is the id of your GCP project and not just the name
(Hint: when you click the drop-down for selecting a certain GCP project in the google cloud console, both the name and the ID of the project will be visibile in the list)
replace "actual_id" with the entity type id
Related to auth:
you need a bearer token in the Authorization header
to get this token you first need to download a JSON key from your projects service account and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your JSON file. More details about setting up the service account and downloading the JSON key, you can find here: https://cloud.google.com/dialogflow/docs/setup
to get the token from the command line you can use
gcloud auth application-default print-access-token

Related

Forge & Jira: Getting 403 when requesting board configuration using requestJira

I'm building a Jira App with Forge where I retrieve board data from the Jira Cloud Rest API. Data retrieval is done in a client-side script using requestJira from #forge/bridge. I'm able to successfully retrieve a list of all boards using the route /rest/agile/1.0/board but when I try to retrieve the configuration of a selected board using the route '/rest/agile/1.0/board/' + boardId + '/configuration' e.g. /rest/agile/1.0/board/4/configuration, this leads to the error response 403 "Forbidden".
In manifest.yml I have defined permissions as follows:
permissions:
scopes:
- read:jira-work
One should think that this should be enough for retrieving board configurations, particularly since the retrieval of the board list was successful. If not, then what is the required permission in this case? Or what else might be going wrong here?
I also tried executing api.asApp().requestJira('/rest/agile/1.0/board/4/configuration',{}) from #forge/api on the server side. Result was the same, i.e. also a 403 response.
The route /rest/agile/1.0/board/4/configuration works fine when pasted into a browser's address field after the URL of my dev instance.

Shopify wishlist app - displaying item information from products.json?

I'm trying to finish the front-end of my shopify wishlist app.
-My app uses a database with each record contains a product ID that the client has wishlisted.
The logic:
-I have a front-end shopify page with a div tag containing the client's ID. (if signed in)
-I use javascript to grab the client's ID and then grab all the product IDs from my app's database.
[Up to this point it works fine, I have the product IDs]
-Now I'm calling axios.post(appDomain + '/api/showWishlist', {shop_id: Shopify.shop,customer_id: customer})
-Inside my api.php file I have: Route::post('showWishlist', 'App\Http\Controllers\WishlistController#show');
-Which then my show function in my wishlistController file has php code that needs to return the product info (name, price, image, etc.) from the store's products.json.
This is where my problem lies. I can't seem to be able to grab the product info based on the ID. My original idea was to use graphQL in my controller function, but I believe that it only works for the website's owner as Auth::user() is required to run the graphQL?
How can I get the shopify product details (name,price,etc.) by using the product's ID from my wishlistController.php file?
Since you are already running an App, your best bet is re-factor it to be embedded (or just installed) in the shop itself, with permission to read products. In the front end, you use the App Proxy to call your App with product ID and customer IDs. You can then call Shopify, get the correct product information based on the IDs, and provide a nice JSON payload back to the front-end, all securely. This is the preferred pattern and without it, you're in for a tough slog. You could try tap-dancing with StorefrontAPI permissions, but still. You also expose your own App to abuse since you make no mention of you are securing your data. With the Shopify embedded App approach, you are protected.

Swagger Authorization keys

In Swagger I have had problems to configure the authorizations.
In Available authorizations there are two fields to fill:
subscription_key (apiKey)Provide your cognitive services subscription key here.Name: Ocp-Apim-Subscription-Key
token (apiKey)
Provide an access token from the JWT returned by the STS of this region. Make sure to add the management scope to the token by adding the following query string to the STS URL: ?scope=speechservicesmanagement
I did not find it clear where I have to get this info.
Could someone help me?
The two paramters can be found as follows:
1. subscription_key parameter: this can be found in Azure portal> Navigate to the Speech service that you must have created (Cognitive Service) or see here to create new Speech service > use the value from Key1
Mine looks like below :
Things to remember :
The speech to text api (especially conversational api) is supported only in specific regions, I chose centralus.
The pricing tier should be S0 Standard to get the apis working (atleast for conversation apis)
2. token (apiKey) parameter :
You will need to generate the token by sending a post request to the speech service endpoint (see image above for location of endpoint url).
Add your subscription key as a header.
The post request will generate the access token as response
Things to remember :
As instructed in swagger, remember to add the query string of '?scope=speechservicesmanagement' to your endpoint url before generating the token.
ex: https://centralus.api.cognitive.microsoft.com/sts/v1.0/issuetoken?scope=speechservicesmanagement

Google Play services leaderboard sample scripts are not running

I am trying to implement Google Leaderboard for my games.
So I have downloaded sample scripts from the following URL: https://github.com/playgameservices/web-basic-samples
and put it in the web server:
E:\wamp\www\sugumar\web-basic-samples-master
and in the browser I tried
http://localhost/sugumar/web-basic-samples-master/type-a-number-js/index.html
but it showed the following error
Not Found
The requested URL
/sugumar/web-basic-samples-master/type-a-number-js/index.html was not
found on this server.
so I checked the file permissions for the folder web-basic-samples-master (I have so many projects running under sugumar folder so no problem with that folder permission).
It was in read only mode, so I unchecked the readonly and clicked on apply and on the next screen I clicked ok for "Apply changes to this folder, subfolders files" and then I clicked on ok, and then run the following url again
http://localhost/sugumar/web-basic-samples-master/type-a-number-js/index.html
but it still shows the same problem:
Not Found
The requested URL
/sugumar/web-basic-samples-master/type-a-number-js/index.html was not
found on this server.
It seems you've skipped the entire Running the sample application guide accompanying the code sample:
To run this sample application in your own environment, perform the
following steps:
1.Get the latest Google APIs Client Library for PHP and extract it into your server directory.
- We recommend you retrieve this using git, to ensure you always have the latest version. (e.g. git clone
https://github.com/google/google-api-php-client)
- Alternately, you can get the gzip file from the downloads page. Please make sure you download version 0.6.2 or later (updated June 3,
2013), as the GameService contrib file does not exist in earlier
versions.
2.This application assumes you have PHP/MySQL already running on your server. Create a users table with the following setup:
CREATE TABLE IF NOT EXISTS `users` ( `temp_key` varchar(128) NOT
> NULL, `user_id` varchar(64) NOT NULL, `bearer_token`
> varchar(1024) NOT NULL, `last_modified` timestamp NOT NULL DEFAULT
> CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY
> (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Create your own application in the Play Console, as described in the Create Client IDs portion of the documentation. Make sure you
follow the "Web" instructions for creating your Client ID and linking
your application.
If you've already set up your own version of the Type-a-Number sample
application, you can repurpose that application here. Either create a
new linked application (which will give you a new client ID), or add
your test server to your list of Javascript Origins in the APIs
Console (which will let you re-use your current client ID)
When you link your Web application, ensure the hostname matches the server from which you'll be testing your application. (e.g.
http://localhost/ or https://www.mytestserver.com). Also, make sure
that you have the right protocol (http vs. https)
Make a note of your Client ID and Client Secret as described in the documentation
Create a Leaderboard as described in the Leaderbords documentation. Give it a creative name like "High scores".
Once that's done, you'll want to replace the following constants defined in the SampleAppConstants.ini file.
In the api section, replace the following: clientId (Replace this with
your OAuth2.0 Client ID) clientSecret (Replace this with your OAuth2.0
Client secret) In the db section, replace the following: user (Replace
this with your MySQL username) pass (Replace this with your MySQL
password) host (Replace this with your MySQL hostname) name (Replace
this with the name of the MySQL database you're using.) In the game
section, replace the following: leaderboardId (Replace this with the
ID of the leaderboard you created in the previous step.)
Move your AppConstants.ini file outside of your htdocs tree. This contains sensitive information and it shouldn't be located anywhere
where it could accidentally be displayed to the user.
Update the constructor in your GameHandler file to point to the new location of AppConstants.ini.
That's it! Your application should be ready to run!

List files current user can edit using Google Drive API

I'm trying to use the Google Drive API in Javascript to get a list of files that the signed in user can edit. How do I do this?
I've tried using a files/list request to get the list of files which gets a list of all files by default:
https://developers.google.com/drive/v2/reference/files/list
The request also accepts search parameters:
https://developers.google.com/drive/search-parameters
e.g. to search for files writeable by the user "test#example.org" use 'test#example.org' in writers
I need to be able to say ' [current user's email address] in writers' or something similar for this to work though and I can't see any way to programmatically get the current user's email address.
Should be able to do that with a query like:
'user#example.com' in owners or 'user#example.com' in writers
That'll return files the current user either owns or it where it was shared with them with edit permissions.

Categories