Created
February 5, 2019 16:46
-
-
Save Fleker/8271469453e8ed0abe3092a85be5ba98 to your computer and use it in GitHub Desktop.
Using Cloud Storage for Firebase for hosting rich media in your Actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(functions.config().firebase); | |
const bucket = admin.storage().bucket(); | |
const bucketAccessConfig = { | |
action: 'read', | |
expires: Date.now() + 1000 * 60 * 60 | |
}; | |
const {dialogflow, BasicCard, Image} = require(‘actions-on-google’); | |
app.intent('basic card', async conv => { | |
const imageFileRef = bucket.file('images/cool-photo.jpg'); | |
const [imageUrl] = await imageFileRef.getSignedUrl(bucketAccessConfig); | |
conv.ask('Here is a card response') | |
conv.ask(new BasicCard({ | |
text: 'This is a basic card', | |
image: new Image({ | |
url: imageUrl, | |
alt: 'Image alternate text' | |
}); | |
})); | |
}); | |
exports.fulfillment = functions.https.onRequest(app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment