Skip to content

Instantly share code, notes, and snippets.

@Fleker
Created February 5, 2019 16:46
Show Gist options
  • Save Fleker/8271469453e8ed0abe3092a85be5ba98 to your computer and use it in GitHub Desktop.
Save Fleker/8271469453e8ed0abe3092a85be5ba98 to your computer and use it in GitHub Desktop.
Using Cloud Storage for Firebase for hosting rich media in your Actions
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