Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Action can change your life! - DevFestSurat18

Action can change your life! - DevFestSurat18

Talk is beautifully crafted for beginners and intermediates who heard about Google Assistant but never explored before. This talk will provide you an extent level of journey how to start with it and for what purposes you can use Action on Google for your applications. Generate Simple Responses and Rich Responses with Basic card and Suggestion Chips.

I will discuss about following topics,

- What and Why Dialogflow
- About Entities, Intents, Integrations
- Creating Actions

Jaldeep Asodariya

November 18, 2018
Tweet

More Decks by Jaldeep Asodariya

Other Decks in Technology

Transcript

  1. Triggering Ok Google, talk to codelabs actions. Surat Hey Google,

    let me talk to codelabs actions. Ask codelabs actions to tell me brief about GDG.
  2. Surat How does it work? Actions on Google Dialogflow Firebase

    Realtime Database Firebase Cloud Functions
  3. Intent Matching - Match and categorize user utterances to an

    intent. Surat Entity Extraction - Identify key words and phrases spoken by the user. “ @
  4. Personalize your responses with helper intents Helper intents return frequently-requested

    information such as the user's name and location actions_intent_PERMISSION
  5. Setup for Firebase Cloud Functions Install firebase command-line interface $

    npm -g install firebase-tools $firebase login $firebase init … $ npm install … $firebase deploy Surat
  6. const { dialogflow, Permission, Suggestions, } = require('actions-on-google'); const functions

    = require('firebase-functions'); const app = dialogflow({ debug: true }); app.intent('Default Welcome Intent', (conv) => { conv.ask(new Permission({ // Asks the user's permission to know their name context: 'Hi there, to get to know you better', permissions: 'NAME', })); }); ... exports.dialogflowWebhook = functions.https.onRequest(app);
  7. ... // Handle the Dialogflow intent named 'actions_intent_PERMISSION'. app.intent('actions_intent_PERMISSION', (conv,

    params, permissionGranted) => { const welcomeResponse = `Hi!, Welcome to Google Developers Groups. What you want to know about this platform?`; if (!permissionGranted) { // If the user denied our request, go ahead with the conversation. conv.ask(`OK, no worries. ` + welcomeResponse); conv.ask(new Suggestions('About GDG Ahmedabad', 'Brief about')); } else { // store their name in the 'conv.data' object conv.data.userName = conv.user.name.display; conv.ask(`Thanks, ${conv.data.userName}. ` + welcomeResponse); conv.ask(new Suggestions('About GDG Ahmedabad', 'Brief about')); } }); ...
  8. ... // Handle the Dialogflow intent named 'brief_chapter'. app.intent(brief_chapter, (conv,

    { chapterName }) => { return platformsRef.once('value', snapshot => { snapshot.forEach(function (childSnapshot) { var chaptersSnapshot = childSnapshot.child(strings.general.fireDatabase.childChapters); }); }); }); ...
  9. ... // Handle the Dialogflow intent named 'brief_chapter'. app.intent(brief_chapter, (conv,

    { chapterName }) => { ... chaptersSnapshot.forEach(function (childSnapshot) { if (chapterName === childSnapshot.val().referenceValue) { // Chapter name Matched console.log('Chapter name Matched'); // Check if current device has screen output and generate response accordingly if (!conv.screen) { conv.ask(childSnapshot.val().aboutBrief); } else { ... } }); }); ...
  10. ... } else { // Generate Rich response with BasicCard

    conv.ask(startingResponse, new BasicCard({ title: childSnapshot.val().name, text: childSnapshot.val().aboutBrief, buttons: new Button({ title: 'Join community', url: childSnapshot.val().url, }), image: new Image({ url: childSnapshot.val().image.url, alt: childSnapshot.val().image.altText, }), })); conv.ask(new Suggestions('About platform', 'About chapter', 'Bye')); } return conv; // return for STOP the loop. }); ...
  11. Surat Jaldeep Asodariya, GDG Ahmedabad @jaldeepasodariy Thank you! Dank je!

    ध यवाद! ধন বাদ! ہﯾرﮑﺷ ﺎﮐ پآ! ﻲﻧﺎﺑرﮭﻣ ﻲﺟ نﺎھوﺗ! ကျေးဇူးတင်ပါတယ်! ന ി! ありがとうございました! Ευχαριστώ! Gràcies! ਤੁਹਾਡਾ ਧੰਨਵਾਦ! ಧನ ಾದ! À ringrazià ti! 谢谢! ந றி! ధన ా ల ! ¡Gracias! Faleminderit! આભાર! ขอขอบคุณ!