How to import Alexa skill into API.AI / Dialogflow? - alexa

I'm trying to export my Alexa Skill / import it into Dialogflow (used to be called API.AI), but I'm getting the following error message:
Invalid Alexa schema json file.
My Zip file is the index.js file and the node_modules folder zipped together. Then I added the Alexa Skill JSON named schema.json to the zip too, but it still gives the same error.
I cannot find instructions on how to export the correct Alexa .zip for import, nor how to format the zip to build it myself. I've been searching for a while -- does anyone know how to do this? (I emailed their support already, but no response yet.)

There were some updates to the Alexa Interaction Model, so the Dialogflow Alexa Importer doesn't seem to work anymore.
There are a few things to consider when porting an Alexa Model into a Dialogflow Agent:
Built-in Intents: You need to create custom Dialogflow intents for built-in Alexa intents like AMAZON.HelpIntent
Built-in Slots: Amazon offers a large variety of slots (e.g. AMAZON.Number) that need to be converted to Dialogflow. For this, Dialogflow offers System Entities. Find all System Entities here.
I created a complete step by step guide and video that uses the Jovo Language Model to translate an Alexa Model into a Dialogflow Agent. You can find it here: Tutorial: Turn an Alexa Interaction Model into a Dialogflow Agent.

Here is an example of the format for the zip: https://github.com/dialogflow/fulfillment-webhook-importer-nodejs/tree/master/skill/speechAssets
The zip should have two files: IntentSchema.json and SampleUtterances.txt
Here is how to get IntentSchema.json and SampleUtterances.txt:
Go to https://developer.amazon.com/edw/home.html#/skills to view all your skills.
Select the skill you'd like to export to by clicking on the skill name for the corresponding skill:
On the left select "Interaction Model" from the list and you should see the screenshot below:
Copy the contents of the the editor and paste it into your IntentSchema.json file and save it.
Next, copy the contents into the editor of the "Sample Utterances" section and paste into your SampleUtterances.txt file and save:
Lastly zip up your IntentSchema.json and SampleUtterances.txt files and upload them to Dialogflow

I'm not sure if your still working on this but if anyone else is stuck, the files you zip have to read IntentSchema.json and SampleUtterances.txt exactly.

Related

Frontend image upload in Typo3 7.4

I'm developing an extension (and website) for a friend who needs to make different profiles for people, comparable to an intranet or online address-book.
The extension works almost great, but I'd like to have an option to upload profile pictures at the frontend in the create and edit action.
The example of Helhum on Github somehow doesn't work on Typo3 7.4. It tells me
An error occurred while trying to call Helhum\UploadExample\Controller\ExampleController->createAction()
image:
Object with identifier "1:/content/" does not exist in storage
Problem might be that you do not have that folder. You can try with default user upload folder like:
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER =>
'1:/user_upload/'

google apps from app engine

I want to produce a Google Apps document based on a (Google doc) template stored on the users Google Drive and some XML data held by a servlet running on Google App Engine.
Preferably I want to run as much as possible on the GAE. Is it possible to run Apps Service APIs on GAE or download/manipulate Google doc on GAE? I have not been able to find anything suitable
One alternative is obviously to implement the merge functionality using an Apps Script transferring the XML as parameters and initiate the script through http from GAE, but it just seem somewhat awkward in comparison.
EDIT:
Specifically I am looking for the replaceText script functionality, as shown in the Apps script snippet below, to be implemented in GAE. Remaining code is supported through Drive/Mail API, I guess..
// Get document template, copy it as a new temp doc, and save the Doc’s id
var copyId = DocsList.getFileById(providedTemplateId)
.makeCopy('My-title')
.getId();
var copyDoc = DocumentApp.openById(copyId);
var copyBody = copyDoc.getActiveSection();
// Replace place holder keys,
copyBody.replaceText("CustomerAddressee", fullName);
var todaysDate = Utilities.formatDate(new Date(), "GMT+2", "dd/MM-yyyy");
copyBody.replaceText("DateToday", todaysDate);
// Save and close the temporary document
copyDoc.saveAndClose();
// Convert temporary document to PDF by using the getAs blob conversion
var pdf = DocsList.getFileById(copyId).getAs("application/pdf");
// Attach PDF and send the email
MailApp.sendEmail({
to: email_address,
subject: "Proposal",
htmlBody: "Hi,<br><br>Here is my file :)<br>Enjoy!<br><br>Regards Tony",
attachments: pdf});
As you already found out, apps script is currently the only one that can access an api to modify google docs. All other ways cannot do it unless you export to another format (like pdf or .doc) then use libraries that can modify those, then reupload the new file asking to convert to a google doc native format, which in some cases would loose some format/comments/named ranges and other google doc features. So like you said, if you must use the google docs api you must call apps script (as a content service). Also note that the sample apps script code you show is old and uses the deptecated docsList so you need to port it to the Drive api.
Apps script pretty much piggy backs on top of the standard published Google APIs. Increasingly the behaviours are becoming more familiar.
Obviously apps script is js based and gae not. All the APIs apart from those related to script running are available in the standard gae client runtimes.
No code to check here so I'm afraid generic answer is all I have.
I see now it can be solved by using the Google Drive API to export (download) the Google Apps Doc file as PDF (or other formats) to GAE, and do simple replace-text editing using e.g. the iText library

Google Drive MD5 checksum for files

I'm not a programmer, just a regular user of Google Drive. I want to see if the files are uploaded correctly. I go through a whole process in the OAuth 2.0 Playground that lists all files, shows the MD5 checksums but also lots of information per file. If I upload a new file it's hard to search for it and verify its md5 checksum.
Is there an easier way (through an app, maybe?) to show/list MD5 checksums for the uploaded files? I wonder why the Details pane doesn't have it, only lists the file size in bytes.
edit: NB these instructions have changed slightly for the v3 API
I've figured out a quick way to get the MD5 checksums of the files uploaded and decided to share it here, too. Log into your Google Drive account, then:
Visit: https://developers.google.com/drive/v3/reference/files/list
Scroll down to the Try it! section.
Change "Authorize requests using OAuth 2.0" from OFF to ON by clicking on it, then select:
https://www.googleapis.com/auth/drive.metadata.readonly
and click Authorize.
Choose your account then click Accept.
Fill in the fields field with:
for v2 API:
items(md5Checksum,originalFilename)
for v3 API:
open "Show standard parameters" in GUI to see fields than
files(md5Checksum,originalFilename)
to only get a list of filenames and MD5 checksums.
Click Execute and you'll open a list with all the files uploaded to Google Drive and their MD5 checksums.
API instructions
Google Developers - OAuth 2.0 Playground:
https://developers.google.com/oauthplayground/
Step 1: Select & authorize APIs:
Expand "Drive API v3".
Enable "https://www.googleapis.com/auth/drive.metadata.readonly".
Click "Authorize APIs".
Click "Allow".
Step 2: Exchange authorization code for tokens:
Click "Exchange authorization code for tokens".
Step 3: Configure request to API:
Enter the "Request URI".
Click "Send the request".
Request URI instructions
All files in folder
Get specific fields of files in a folder:
https://www.googleapis.com/drive/v3/files?q="folderId"+in+parents&fields=files(md5Checksum,+originalFilename)
//
Replace "folderId" with the folder ID.
You can use &fields=files(*) to get all of the file's fields.
Single file
Get specific fields of a file:
https://www.googleapis.com/drive/v3/files/fileId?fields=md5Checksum,+originalFilename
//
Replace "fileId" with the file ID.
You can use &fields=* to get all of the file's fields.
Parsing the JSON response
Open a JavaScript console.
Save the object into a variable.
Map the object.
Copy the result.
Code
var response = {
"files": [
{
"md5Checksum": "0cc175b9c0f1b6a831c399e269772661",
"originalFilename": "a.txt"
},
{
"md5Checksum": "92eb5ffee6ae2fec3ad71c777531578f",
"originalFilename": "b.txt"
}
]
};
var result = response.files.map(function (file) { return (file.md5Checksum + " *" + file.originalFilename); }).join("\r\n");
console.log(result);
copy(result);
Here are three additional, different ways to list md5 checksums.
Install Google Skicka, a command line tool for Google Drive and run skicka ls -ll /
Although the readme file says it's not an official google product it is hosted on google's github account, so I guess it can be trusted.
There is a plugin that lists all files with their checksums in drive's spreadsheet.
Here's my python3 script that I've created for myself. It's mostly copied from google's official examples. You'll need to obtain client_secret.json file and place it in the same directory with the script - here's the instruction how to do it.
Based on: Alex's above answer!
Click the link : https://developers.google.com/drive/v3/reference/files/list
Click the Try it now link in the middle.
( An active window appears in the middle )
Scroll down the left pane in the active window.
Under fields section on the left pane, fill
files(md5Checksum,originalFilename)
Now we will limit access scopes :
(i) leave the Google OAuth 2.0 selected & clear the box against API key.
(ii) Expand Show scopes under Google OAuth 2.0
(iii) Clear all the scopes but keep this one selected:
**https: //www.googleapis.com/auth/drive.metadata.readonly**
Now click EXECUTE in blue.
(A new Google Sign In Window will open)
Use that window to Sign in with the respective google account & click Allow to permit the Google APIs Explorer access files in your google drive.
It's done! A new window will open with the results in lower right code pane. It will
provide the names & md5Checksums for all the files in the respective google
drive account.
Click outside of the active window to close the window & close the Google Drive
API tab. Now you can sign out of the google account if you want!
Combined with XP1 and Alex guides to work in my scenario, to list MD5 for private folders that shared with me
-includeItemsFromAllDrives
-includeTeamDriveItems
-supportsAllDrives
-supportsTeamDrives
Request URI in OAuth 2.0 Playground
https://www.googleapis.com/drive/v3/files?q="folderID"+in+parents&includeItemsFromAllDrives=true&includeTeamDriveItems=true&supportsAllDrives=true&supportsTeamDrives=true&fields=files(md5Checksum%2CoriginalFilename)

From Drive to Blobstore using Picker

I have the Google picker set up, as well as Blobstore. I'm able to upload files from my local machine to the Blobstore, but now I have the Picker set up, it works, but I don't know know how to use the info (url? fileid?) to then load that selected file into the Blobstore? Any tips on how to do this? I haven't been able to find much of anything on it on Googles resources
There isn't a direct link between the Google Picker and the App Engine Blobstore. They are kind of different tools for different jobs. The Google Picker is designed as an end user tool, to select data from a users Google account. It just so happens that the Picker also provides an upload interface (to Google Drive) as well. The Blobstore on the other hand, is designed as a blob storage mechanism for your App Engine application.
In theory, you could write a script to connect the two, but there are a few considerations:
Your app would need access to the users Google Drive account using OAuth2. This is necessary, as the Picker API is a client side API, whereas the Blobstore API is a server side API. You would need to send the selected document URL to the server, then download the document and finally save it to Blobstore.
Unless you then deleted the data from Drive (very risky due to point 3), your data would be persisted in 2 places
You cannot know for sure if the user selected an existing file, or uploaded a new one
Not a great user experience - the user things they are uploading to Drive
In essence, this sounds like a bad idea! What is your use case?
#Gwyn - I don't have enough reputation to add a comment to your solution, but I had an idea about problem #3: You cannot know for sure if the user selected an existing file, or uploaded a new one
Would it be possible to use Response.VIEW to see what view they were using when the file was selected? If you have one view constructor for Drive files and one for Upload files, something like
var driveView = new google.picker.View(google.picker.ViewId.DOCS);
var uploadView = new google.picker.DocsUploadView();
would that allow you to know whether the file was a new upload (safe to delete) or an existing file (leave it alone)?
Assuming that you want to pick a file from your own Google Drive and move it to the Blobstore.
1)First you have to perform Oauth for Google Drive API
2)Using the picker when you select a file from drive, you need to get it's id
3)Using the id obtained in step 2 you can programmatically download it using Drive API
4)After downloading the file you can use FileService(deprecated though) to upload the file to the
Blobstore.

CAN I use Google Application Engine to implement this project?

I take web application course this semester and I want to use google application engine to implement my course project, but I'm wondering if GAE can satisfy this project's requirements.
This course project is a homework submittal system which allows users(students) uploading homework to the sever and teachers checking homework online.
Assuming homework students uploaded is some html and css stuff. What confused me is how to implemnent teacher checking online function? For example:
Student A uploaded a html file hello.html and teacher want to use http: //xxx.xx/xx/xx/hello.html to check this homework.
Can GAE satisfy this requirement? As far as I konw, GAE uses app.yaml to point to different files or htmls, but when students upload their homework, they can not change app.yaml,right?
I get stuck here. Please help me. Thank you!
Yes, you can use GAE to create this application, but you'll have to move away from the idea that you are uploading and serving an HTML file as if it were living directly on the filesystem. You can't do that.
What you can do -- relatively easily -- is store the submitted file or files as datastore objects and provide a URL which takes the desired filename as a parameter and serves it out of the datastore.
You could store the submitted files in a model like this:
class HomeworkItem(db.Model):
author = db.UserProperty()
filename = db.StringProperty()
content = db.TextProperty(multiline=True)
submitted_on = db.DateProperty()
The content field is declared as a TextProperty assuming that you are dealing with HTML and CSS files, but if you were ever going to deal dealing with binary data, you'd want to use a BlobProperty.
You'd need to have two URLs to handle upload and download of assets. You can use a web framework or write some code to handle parameterized URLs, allowing you to encode things like the filename into the URL itself, like this:
http://homeworkapp.edu/review/hello.html
And then the method that handles /review/* URLs would retrieve the data from the datastore and send it back as the reply.
GAE would satisfy your requirement but you would need to save each “hello.html” file in either the Blobstore or the Datastore and build some system to retrieve and serve the uploaded files. See this Q&A for further reference.

Resources