Skip to content

Instantly share code, notes, and snippets.

@Fleker
Created February 5, 2019 16:45
Show Gist options
  • Save Fleker/a585e96460ada2aeaf7d0ac403aeb9d7 to your computer and use it in GitHub Desktop.
Save Fleker/a585e96460ada2aeaf7d0ac403aeb9d7 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} = require(‘actions-on-google’);
const app = new dialogflow();
app.intent('ssml response', async conv => {
const soundFileRef = bucket.file('audio/sound-effect.mp3');
const [soundUrl] = await soundFileRef.getSignedUrl(bucketAccessConfig);
conv.ask(`<speak>I can return some text, then a sound effect.
<audio src="${soundUrl}"></audio>
</speak>`);
});
exports.fulfillment = functions.https.onRequest(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment