Created
February 5, 2019 16:45
-
-
Save Fleker/a585e96460ada2aeaf7d0ac403aeb9d7 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} = 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