Skip to main content

Command Palette

Search for a command to run...

Creating a StoryTelling Action in Google Assistant — Part 2

Published
2 min read
Creating a StoryTelling Action in Google Assistant — Part 2

Photo by Thomas Kolnowski on Unsplash

Welcome back to Part 2 of storytelling action in google assistant. If you are new have a look at Part 1 of creation dialog flow for storytelling action.

Let’s create the backend part for our storytelling action using firebase cloud function.

Folder structure for the storytelling action would be like this

We will import the dialog flow module and response creation dependencies

We will add the code for the welcome intent

Whenever the action is opened it will show the title and fetch the stories

We have written a logic to shuffle the stories each time when the user opens the action

We have kept the stories in a separate file named stories.js

To show the stories in carousel effect

We have handled for both cases that are displaying the action in the smartphone as well as in smart speakers

Once the user selects a story it will be passed to the media object

Where it will start to play the mp3 file

Once the media object gets started to play we can stop the audio for that we need to handle the media response

If the user says yes or no we should handle the case using the below intent

If there is no response from the user means

We have linked all the intents we created in the dialog flow and it’s time to deploy our function to firebase using the command

firebase deploy

once deployed copy the URL and go to dialog flow

Click fulfillments and paste the URL in webhook

Click save

Now it’s time for testing your action

The end output would be like

Congratulations you have created an action in dialog flow using firebase go ahead and publish your action

Cartoon Stories — Find out the skill in google assistant

Here are the gist files for the storytelling actions

index.js

storyAudio.js

stories.js

More from this blog