ज़्यादा बेहतर जवाब (Dialogflow)

Dialogflow में जानें

Dialogflow में हमारे जवाबों के सैंपल को इंपोर्ट करने के लिए, जारी रखें पर क्लिक करें. इसके बाद, सैंपल को डिप्लॉय और टेस्ट करने के लिए, यह तरीका अपनाएं:

  1. एजेंट का नाम डालें और सैंपल के लिए, नया Dialogflow एजेंट बनाएं.
  2. एजेंट इंपोर्ट हो जाने के बाद, एजेंट पर जाएं पर क्लिक करें.
  3. मुख्य नेविगेशन मेन्यू से, पूरा किया गया पर जाएं.
  4. इनलाइन एडिटर को चालू करें. इसके बाद, डिप्लॉय करें पर क्लिक करें. एडिटर में सैंपल कोड होता है.
  5. मुख्य नेविगेशन मेन्यू में, इंटिग्रेशन पर जाएं. इसके बाद, Google Assistant पर क्लिक करें.
  6. इसके बाद दिखने वाली मोडल विंडो में, बदलावों की ऑटो-झलक देखने की सुविधा को चालू करें. इसके बाद, ऐक्शन सिम्युलेटर खोलने के लिए, जांच करें पर क्लिक करें.
  7. नमूने की जांच करने के लिए सिम्युलेटर में, Talk to my test app डालें!
जारी रखें

अगर अपनी सेट की गई कार्रवाई के साथ उपयोगकर्ता के इंटरैक्शन को बेहतर बनाने के लिए विज़ुअल एलिमेंट दिखाने हैं, तो ज़्यादा बेहतर रिस्पॉन्स का इस्तेमाल करें. ये विज़ुअल एलिमेंट, बातचीत जारी रखने के तरीके पर संकेत दे सकते हैं.

पूरी जानकारी वाले जवाब, सिर्फ़ स्क्रीन पर या ऑडियो और स्क्रीन पर दिख सकते हैं. इनमें ये कॉम्पोनेंट शामिल हो सकते हैं:

अपनी सेट की गई कार्रवाई में इन विज़ुअल एलिमेंट को शामिल करने का तरीका जानने के लिए, हमारे बातचीत डिज़ाइन करने से जुड़े दिशा-निर्देश भी देखे जा सकते हैं.

प्रॉपर्टी

बेहतर रिस्पॉन्स में नीचे दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं, जिन्हें कॉन्फ़िगर किया जा सकता है:

  • actions.capability.SCREEN_OUTPUT क्षमता वाले प्लैटफ़ॉर्म पर काम करती है.
  • रिच रिस्पॉन्स में पहला आइटम आसान जवाब होना चाहिए.
  • ज़्यादा से ज़्यादा दो आसान जवाब.
  • ज़्यादा से ज़्यादा एक बेसिक कार्ड या StructuredResponse.
  • ज़्यादा से ज़्यादा आठ सुझाव देने वाले चिप शामिल किए जा सकते हैं.
  • FinalResponse में सुझाव वाले चिप इस्तेमाल करने की अनुमति नहीं है
  • फ़िलहाल, स्मार्ट डिसप्ले के ज़रिए वेब से लिंक करने की सुविधा उपलब्ध नहीं है.

यहां दिए गए सेक्शन में, अलग-अलग तरह के रिच रिस्पॉन्स बनाने का तरीका बताया गया है.

बुनियादी कार्ड

पहली इमेज. बुनियादी कार्ड का उदाहरण (स्मार्टफ़ोन)

बुनियादी कार्ड में यह जानकारी दिखती है:

  • इमेज
  • टाइटल
  • सब-टाइटल
  • टेक्स्ट का मुख्य हिस्सा
  • लिंक बटन
  • बॉर्डर

मुख्य रूप से दिखाने के लिए बेसिक कार्ड का इस्तेमाल करें. इन्हें इस तरह से डिज़ाइन किया गया है कि उपयोगकर्ताओं को कम शब्दों में मुख्य या खास जानकारी दी जा सके. साथ ही, इस तरह से तैयार किया गया हो कि उपयोगकर्ता (वेबलिंक का इस्तेमाल करके) आपकी पसंद के हिसाब से, ज़्यादा जानकारी पा सकें.

ज़्यादातर स्थितियों में, आपको बातचीत जारी रखने या उसमें बदलाव करने के लिए कार्ड के नीचे सुझाव देने वाले चिप जोड़ने चाहिए.

चैट बबल में कार्ड में दी गई जानकारी को दोहराने से बचें.

प्रॉपर्टी

बेसिक कार्ड रिस्पॉन्स टाइप में नीचे दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं, जिन्हें कॉन्फ़िगर किया जा सकता है:

  • actions.capability.SCREEN_OUTPUT क्षमता वाले प्लैटफ़ॉर्म पर काम करती है.
  • फ़ॉर्मैट किया गया टेक्स्ट (अगर कोई इमेज नहीं है, तो यह ज़रूरी है)
    • डिफ़ॉल्ट रूप से सादा टेक्स्ट.
    • इसमें लिंक नहीं होना चाहिए.
    • इमेज के साथ 10 लाइन की सीमा, इमेज के बिना 15 लाइन की सीमा. यह करीब 500 (इमेज के साथ) या 750 (इमेज के बिना) वर्ण होते हैं. छोटी स्क्रीन वाले फ़ोन भी बड़ी स्क्रीन वाले फ़ोन के मुकाबले पहले टेक्स्ट में काट-छांट करते हैं. अगर टेक्स्ट में कई लाइनें हैं, तो आखिरी शब्द ब्रेक में उन्हें एलिप्सिस से छोटा कर दिया जाता है.
    • Markdown का एक सीमित सबसेट ही इस्तेमाल किया जा सकता है:
      • डबल स्पेस वाली नई लाइन के बाद \n
      • **bold**
      • *italics*
  • इमेज (अगर फ़ॉर्मैट किया गया टेक्स्ट न हो, तो ज़रूरी है)
    • सभी इमेज की लंबाई 192 dp से सेट की गई.
    • अगर इमेज का आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात) स्क्रीन से अलग है, तो इमेज को वर्टिकल या हॉरिज़ॉन्टल किनारों पर स्लेटी रंग के बार के बीच में रखा जाता है.
    • इमेज का सोर्स एक यूआरएल है.
    • मोशन GIF की अनुमति है.

ज़रूरी नहीं

  • टाइटल
    • सामान्य टेक्स्ट.
    • तय फ़ॉन्ट और साइज़.
    • ज़्यादा से ज़्यादा एक लाइन; अतिरिक्त वर्णों को काट दिया जाता है.
    • अगर कोई टाइटल नहीं दिया गया है, तो कार्ड की ऊंचाई कम हो जाती है.
  • सब-टाइटल
    • सामान्य टेक्स्ट.
    • फ़ॉन्ट और फ़ॉन्ट का तय साइज़.
    • ज़्यादा से ज़्यादा एक लाइन; अतिरिक्त वर्णों को काट दिया जाता है.
    • अगर कोई सबटाइटल नहीं दिया गया है, तो कार्ड की ऊंचाई कम हो जाती है.
  • लिंक बटन
    • लिंक का टाइटल डालना ज़रूरी है
    • ज़्यादा से ज़्यादा एक लिंक
    • डेवलपर के डोमेन से बाहर की साइटों को लिंक करने की अनुमति है.
    • लिंक टेक्स्ट गुमराह करने वाला नहीं होना चाहिए. इसकी जांच मंज़ूरी की प्रोसेस में की जाती है.
    • बुनियादी कार्ड में लिंक के बिना इंटरैक्शन की कोई सुविधा नहीं होती. लिंक पर टैप करने से उपयोगकर्ता को लिंक पर भेज दिया जाता है, जबकि कार्ड का मुख्य हिस्सा बंद रहता है.
  • बॉर्डर
    • कार्ड और इमेज कंटेनर के बीच के बॉर्डर में बदलाव किया जा सकता है, ताकि आपके बेसिक कार्ड की प्रज़ेंटेशन को पसंद के मुताबिक बनाया जा सके.
    • JSON स्ट्रिंग प्रॉपर्टी imageDisplayOptions सेट करके कॉन्फ़िगर की गई
दूसरी इमेज. बुनियादी कार्ड का उदाहरण (स्मार्ट डिसप्ले)

नमूना कोड

Node.js

app.intent('Basic Card', (conv) => {
  if (!conv.screen) {
    conv.ask('Sorry, try this on a screen device or select the ' +
      'phone surface in the simulator.');
    conv.ask('Which response would you like to see next?');
    return;
  }

  conv.ask(`Here's an example of a basic card.`);
  conv.ask(new BasicCard({
    text: `This is a basic card.  Text in a basic card can include "quotes" and
    most other unicode characters including emojis.  Basic cards also support
    some markdown formatting like *emphasis* or _italics_, **strong** or
    __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
    things like line  \nbreaks`, // Note the two spaces before '\n' required for
                                 // a line break to be rendered in the card.
    subtitle: 'This is a subtitle',
    title: 'Title: this is a title',
    buttons: new Button({
      title: 'This is a button',
      url: 'https://assistant.google.com/',
    }),
    image: new Image({
      url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
      alt: 'Image alternate text',
    }),
    display: 'CROPPED',
  }));
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("Basic Card")
public ActionResponse basicCard(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
    return responseBuilder
        .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
        .add("Which response would you like to see next?")
        .build();
  }

  // Prepare formatted text for card
  String text =
      "This is a basic card.  Text in a basic card can include \"quotes\" and\n"
          + "  most other unicode characters including emoji \uD83D\uDCF1. Basic cards also support\n"
          + "  some markdown formatting like *emphasis* or _italics_, **strong** or\n"
          + "  __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other\n"
          + "  things like line  \\nbreaks"; // Note the two spaces before '\n' required for
  // a line break to be rendered in the card.
  responseBuilder
      .add("Here's an example of a basic card.")
      .add(
          new BasicCard()
              .setTitle("Title: this is a title")
              .setSubtitle("This is a subtitle")
              .setFormattedText(text)
              .setImage(
                  new Image()
                      .setUrl(
                          "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                      .setAccessibilityText("Image alternate text"))
              .setImageDisplayOptions("CROPPED")
              .setButtons(
                  new ArrayList<Button>(
                      Arrays.asList(
                          new Button()
                              .setTitle("This is a Button")
                              .setOpenUrlAction(
                                  new OpenUrlAction().setUrl("https://assistant.google.com"))))))
      .add("Which response would you like to see next?");

  return responseBuilder.build();
}

Node.js

if (!conv.screen) {
  conv.ask('Sorry, try this on a screen device or select the ' +
    'phone surface in the simulator.');
  conv.ask('Which response would you like to see next?');
  return;
}

conv.ask(`Here's an example of a basic card.`);
conv.ask(new BasicCard({
  text: `This is a basic card.  Text in a basic card can include "quotes" and
  most other unicode characters including emojis.  Basic cards also support
  some markdown formatting like *emphasis* or _italics_, **strong** or
  __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
  things like line  \nbreaks`, // Note the two spaces before '\n' required for
                               // a line break to be rendered in the card.
  subtitle: 'This is a subtitle',
  title: 'Title: this is a title',
  buttons: new Button({
    title: 'This is a button',
    url: 'https://assistant.google.com/',
  }),
  image: new Image({
    url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
    alt: 'Image alternate text',
  }),
  display: 'CROPPED',
}));
conv.ask('Which response would you like to see next?');

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
  return responseBuilder
      .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
      .add("Which response would you like to see next?")
      .build();
}

// Prepare formatted text for card
String text =
    "This is a basic card.  Text in a basic card can include \"quotes\" and\n"
        + "  most other unicode characters including emoji \uD83D\uDCF1. Basic cards also support\n"
        + "  some markdown formatting like *emphasis* or _italics_, **strong** or\n"
        + "  __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other\n"
        + "  things like line  \\nbreaks"; // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
responseBuilder
    .add("Here's an example of a basic card.")
    .add(
        new BasicCard()
            .setTitle("Title: this is a title")
            .setSubtitle("This is a subtitle")
            .setFormattedText(text)
            .setImage(
                new Image()
                    .setUrl(
                        "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                    .setAccessibilityText("Image alternate text"))
            .setImageDisplayOptions("CROPPED")
            .setButtons(
                new ArrayList<Button>(
                    Arrays.asList(
                        new Button()
                            .setTitle("This is a Button")
                            .setOpenUrlAction(
                                new OpenUrlAction().setUrl("https://assistant.google.com"))))))
    .add("Which response would you like to see next?");

return responseBuilder.build();

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Here's an example of a basic card."
            }
          },
          {
            "basicCard": {
              "title": "Title: this is a title",
              "subtitle": "This is a subtitle",
              "formattedText": "This is a basic card.  Text in a basic card can include \"quotes\" and\n    most other unicode characters including emojis.  Basic cards also support\n    some markdown formatting like *emphasis* or _italics_, **strong** or\n    __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other\n    things like line  \nbreaks",
              "image": {
                "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                "accessibilityText": "Image alternate text"
              },
              "buttons": [
                {
                  "title": "This is a button",
                  "openUrlAction": {
                    "url": "https://assistant.google.com/"
                  }
                }
              ],
              "imageDisplayOptions": "CROPPED"
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which response would you like to see next?"
            }
          }
        ]
      }
    }
  }
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Here's an example of a basic card."
              }
            },
            {
              "basicCard": {
                "title": "Title: this is a title",
                "subtitle": "This is a subtitle",
                "formattedText": "This is a basic card.  Text in a basic card can include \"quotes\" and\n    most other unicode characters including emojis.  Basic cards also support\n    some markdown formatting like *emphasis* or _italics_, **strong** or\n    __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other\n    things like line  \nbreaks",
                "image": {
                  "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                  "accessibilityText": "Image alternate text"
                },
                "buttons": [
                  {
                    "title": "This is a button",
                    "openUrlAction": {
                      "url": "https://assistant.google.com/"
                    }
                  }
                ],
                "imageDisplayOptions": "CROPPED"
              }
            },
            {
              "simpleResponse": {
                "textToSpeech": "Which response would you like to see next?"
              }
            }
          ]
        }
      }
    }
  ]
}
तीसरी इमेज. ब्राउज़िंग कैरसेल का उदाहरण (स्मार्टफ़ोन)

ब्राउज़िंग कैरसेल एक रिच रिस्पॉन्स होता है. इससे उपयोगकर्ता, वर्टिकल तौर पर स्क्रोल करके, कलेक्शन में कोई टाइल चुन सकते हैं. ब्राउज़िंग कैरसेल, वेब कॉन्टेंट के लिए खास तौर पर बनाए जाते हैं. इसके लिए, चुनी गई टाइल को किसी वेब ब्राउज़र में (या अगर सभी टाइल पर एएमपी की सुविधा चालू होती है, तो एएमपी ब्राउज़र में) खोला जा सकता है. ब्राउज़िंग कैरसेल उपयोगकर्ता के Assistant प्लैटफ़ॉर्म पर भी दिखता है, ताकि बाद में ब्राउज़ किया जा सके.

प्रॉपर्टी

ब्राउज़िंग कैरसेल रिस्पॉन्स टाइप में नीचे दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं, जिन्हें कॉन्फ़िगर किया जा सकता है:

  • यह ऐसे प्लैटफ़ॉर्म पर काम करती है जिनमें actions.capability.SCREEN_OUTPUT और actions.capability.WEB_BROWSER, दोनों की सुविधाएं हैं. फ़िलहाल, यह रिस्पॉन्स टाइप स्मार्ट डिसप्ले पर उपलब्ध नहीं है.
  • ब्राउज़िंग कैरसेल
    • ज़्यादा से ज़्यादा 10 टाइल.
    • कम से कम दो टाइल होनी चाहिए.
    • कैरसेल में शामिल टाइल को वेब कॉन्टेंट से लिंक किया जाना चाहिए (हमारा सुझाव है कि एएमपी कॉन्टेंट का इस्तेमाल किया जाए).
      • उपयोगकर्ता को एएमपी व्यूअर पर ले जाने के लिए, एएमपी कॉन्टेंट टाइल पर urlHintType, "एएमपी_CONTENT" पर सेट होना चाहिए.
  • ब्राउज़िंग कैरसेल टाइल
    • टाइल एक जैसी होनी चाहिए (ज़रूरी है):
      • ब्राउज़िंग कैरसेल में मौजूद सभी टाइल के कॉम्पोनेंट एक जैसे होने चाहिए. उदाहरण के लिए, अगर एक टाइल में इमेज फ़ील्ड है, तो कैरसेल की बाकी टाइल में भी इमेज फ़ील्ड होने चाहिए.
      • अगर ब्राउज़िंग कैरसेल में मौजूद सभी टाइल, एएमपी की सुविधा वाले कॉन्टेंट से लिंक होती हैं, तो उपयोगकर्ता को अतिरिक्त सुविधाओं वाले एएमपी ब्राउज़र पर ले जाया जाता है. अगर कोई टाइल, बिना एएमपी वाले कॉन्टेंट से लिंक है, तो सभी टाइल, उपयोगकर्ताओं को वेब ब्राउज़र पर ले जाती हैं.
    • इमेज (ज़रूरी नहीं)
      • इमेज की चौड़ाई 128 dp की लंबाई x 232 dp चौड़ी होनी चाहिए.
      • अगर इमेज का आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात) इमेज बाउंडिंग बॉक्स से मेल नहीं खाता, तो इमेज के बीच में बार के दोनों ओर बार होने चाहिए. स्मार्टफ़ोन पर, इमेज को स्क्वेयर में बीच में दिखाया जाता है और इसके कोने गोल होते हैं.
      • अगर इमेज का लिंक काम नहीं करता है, तो प्लेसहोल्डर इमेज का इस्तेमाल किया जाता है.
      • इमेज पर वैकल्पिक लेख होना ज़रूरी है.
    • टाइटल (ज़रूरी है)
      • फ़ॉर्मैटिंग के वही विकल्प जो बेसिक टेक्स्ट कार्ड में इस्तेमाल किए गए हैं.
      • टाइटल यूनीक होने चाहिए, ताकि आवाज़ चुनने में मदद मिल सके.
      • टेक्स्ट की ज़्यादा से ज़्यादा दो लाइनें.
      • फ़ॉन्ट साइज़ 16 sp.
    • जानकारी (ज़रूरी नहीं)
      • फ़ॉर्मैटिंग के वही विकल्प जो बेसिक टेक्स्ट कार्ड में इस्तेमाल किए गए हैं.
      • टेक्स्ट की ज़्यादा से ज़्यादा चार लाइनें.
      • एलिप्सिस (...) के साथ काटे गए
      • फ़ॉन्ट साइज़ 14sp, स्लेटी रंग.
    • फ़ुटर (ज़रूरी नहीं)
      • फ़ॉन्ट और फ़ॉन्ट का तय साइज़.
      • टेक्स्ट की ज़्यादा से ज़्यादा एक लाइन.
      • एलिप्सिस (...) के साथ काटे गए
      • इसे सबसे नीचे रखा जाता है, इसलिए मुख्य टेक्स्ट की कम लाइनों वाली टाइल में सब-टेक्स्ट के ऊपर खाली जगह हो सकती है.
      • फ़ॉन्ट साइज़ 14sp, स्लेटी रंग.
  • इंटरैक्शन
    • आइटम देखने के लिए उपयोगकर्ता वर्टिकल रूप से स्क्रोल कर सकता है.
    • कार्ड पर टैप करना: किसी आइटम पर टैप करने से उपयोगकर्ता, ब्राउज़र पर पहुंच जाता है. वहां, लिंक किया गया पेज दिखता है.
  • बोलकर फ़ोन को निर्देश देना
    • माइक का व्यवहार
      • उपयोगकर्ता को ब्राउज़िंग कैरसेल भेजे जाने पर, माइक फिर से नहीं खुलता.
      • उपयोगकर्ता अब भी माइक को फिर से खोलने के लिए, माइक पर टैप कर सकता है या Assistant ("Ok Google") पर टैप कर सकता है.

दिशा-निर्देश

ब्राउज़ कैरसेल भेजने के बाद, डिफ़ॉल्ट रूप से माइक बंद रहता है. अगर आपको बाद में भी बातचीत जारी रखनी है, तो हमारा सुझाव है कि आप कैरसेल के नीचे सुझाव देने वाले चिप जोड़ें.

सूची में दिए गए विकल्पों को कभी भी सुझाव वाले चिप के तौर पर न दोहराएं. इस संदर्भ में चिप का इस्तेमाल बातचीत को बदलने के लिए किया जाता है (विकल्प चुनने के लिए नहीं).

सूचियों की तरह ही, कैरसेल कार्ड के साथ मौजूद चैट बबल, ऑडियो का सबसेट (टीटीएस/एसएसएमएल) होता है. यहां दिया गया ऑडियो (TTS/SSML), कैरसेल में पहली टाइल को इंटिग्रेट करता है. साथ ही, हम कैरसेल के सभी एलिमेंट को पढ़ने का सुझाव भी नहीं देते. पहली चीज़ और उसे यहां दिखाने की वजह बताना सबसे अच्छा है (उदाहरण के लिए, सबसे लोकप्रिय आइटम, सबसे हाल में खरीदा गया आइटम, सबसे ज़्यादा चर्चित आइटम).

नमूना कोड

app.intent('Browsing Carousel', (conv) => {
  if (!conv.screen
    || !conv.surface.capabilities.has('actions.capability.WEB_BROWSER')) {
    conv.ask('Sorry, try this on a phone or select the ' +
      'phone surface in the simulator.');
      conv.ask('Which response would you like to see next?');
    return;
  }

  conv.ask(`Here's an example of a browsing carousel.`);
  conv.ask(new BrowseCarousel({
    items: [
      new BrowseCarouselItem({
        title: 'Title of item 1',
        url: 'https://example.com',
        description: 'Description of item 1',
        image: new Image({
          url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
          alt: 'Image alternate text',
        }),
        footer: 'Item 1 footer',
      }),
      new BrowseCarouselItem({
        title: 'Title of item 2',
        url: 'https://example.com',
        description: 'Description of item 2',
        image: new Image({
          url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
          alt: 'Image alternate text',
        }),
        footer: 'Item 2 footer',
      }),
    ],
  }));
});
@ForIntent("Browsing Carousel")
public ActionResponse browseCarousel(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())
      || !request.hasCapability(Capability.WEB_BROWSER.getValue())) {
    return responseBuilder
        .add("Sorry, try this on a phone or select the phone surface in the simulator.")
        .add("Which response would you like to see next?")
        .build();
  }

  responseBuilder
      .add("Here's an example of a browsing carousel.")
      .add(
          new CarouselBrowse()
              .setItems(
                  new ArrayList<CarouselBrowseItem>(
                      Arrays.asList(
                          new CarouselBrowseItem()
                              .setTitle("Title of item 1")
                              .setDescription("Description of item 1")
                              .setOpenUrlAction(new OpenUrlAction().setUrl("https://example.com"))
                              .setImage(
                                  new Image()
                                      .setUrl(
                                          "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                                      .setAccessibilityText("Image alternate text"))
                              .setFooter("Item 1 footer"),
                          new CarouselBrowseItem()
                              .setTitle("Title of item 2")
                              .setDescription("Description of item 2")
                              .setOpenUrlAction(new OpenUrlAction().setUrl("https://example.com"))
                              .setImage(
                                  new Image()
                                      .setUrl(
                                          "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                                      .setAccessibilityText("Image alternate text"))
                              .setFooter("Item 2 footer")))));

  return responseBuilder.build();
}
if (!conv.screen
  || !conv.surface.capabilities.has('actions.capability.WEB_BROWSER')) {
  conv.ask('Sorry, try this on a phone or select the ' +
    'phone surface in the simulator.');
    conv.ask('Which response would you like to see next?');
  return;
}

conv.ask(`Here's an example of a browsing carousel.`);
conv.ask(new BrowseCarousel({
  items: [
    new BrowseCarouselItem({
      title: 'Title of item 1',
      url: 'https://example.com',
      description: 'Description of item 1',
      image: new Image({
        url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
        alt: 'Image alternate text',
      }),
      footer: 'Item 1 footer',
    }),
    new BrowseCarouselItem({
      title: 'Title of item 2',
      url: 'https://example.com',
      description: 'Description of item 2',
      image: new Image({
        url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
        alt: 'Image alternate text',
      }),
      footer: 'Item 2 footer',
    }),
  ],
}));
ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())
    || !request.hasCapability(Capability.WEB_BROWSER.getValue())) {
  return responseBuilder
      .add("Sorry, try this on a phone or select the phone surface in the simulator.")
      .add("Which response would you like to see next?")
      .build();
}

responseBuilder
    .add("Here's an example of a browsing carousel.")
    .add(
        new CarouselBrowse()
            .setItems(
                new ArrayList<CarouselBrowseItem>(
                    Arrays.asList(
                        new CarouselBrowseItem()
                            .setTitle("Title of item 1")
                            .setDescription("Description of item 1")
                            .setOpenUrlAction(new OpenUrlAction().setUrl("https://example.com"))
                            .setImage(
                                new Image()
                                    .setUrl(
                                        "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                                    .setAccessibilityText("Image alternate text"))
                            .setFooter("Item 1 footer"),
                        new CarouselBrowseItem()
                            .setTitle("Title of item 2")
                            .setDescription("Description of item 2")
                            .setOpenUrlAction(new OpenUrlAction().setUrl("https://example.com"))
                            .setImage(
                                new Image()
                                    .setUrl(
                                        "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                                    .setAccessibilityText("Image alternate text"))
                            .setFooter("Item 2 footer")))));

return responseBuilder.build();

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Here's an example of a browsing carousel."
            }
          },
          {
            "carouselBrowse": {
              "items": [
                {
                  "title": "Title of item 1",
                  "openUrlAction": {
                    "url": "https://example.com"
                  },
                  "description": "Description of item 1",
                  "footer": "Item 1 footer",
                  "image": {
                    "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                    "accessibilityText": "Image alternate text"
                  }
                },
                {
                  "title": "Title of item 2",
                  "openUrlAction": {
                    "url": "https://example.com"
                  },
                  "description": "Description of item 2",
                  "footer": "Item 2 footer",
                  "image": {
                    "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                    "accessibilityText": "Image alternate text"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Here's an example of a browsing carousel."
              }
            },
            {
              "carouselBrowse": {
                "items": [
                  {
                    "description": "Description of item 1",
                    "footer": "Item 1 footer",
                    "image": {
                      "accessibilityText": "Image alternate text",
                      "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png"
                    },
                    "openUrlAction": {
                      "url": "https://example.com"
                    },
                    "title": "Title of item 1"
                  },
                  {
                    "description": "Description of item 2",
                    "footer": "Item 2 footer",
                    "image": {
                      "accessibilityText": "Image alternate text",
                      "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png"
                    },
                    "openUrlAction": {
                      "url": "https://example.com"
                    },
                    "title": "Title of item 2"
                  }
                ]
              }
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ]
    }
  ]
}

चुने गए आइटम को मैनेज करना

ब्राउज़ कैरसेल आइटम के साथ उपयोगकर्ता इंटरैक्शन के लिए फ़ॉलो-अप फ़ुलफ़िलमेंट की ज़रूरत नहीं है, क्योंकि कैरसेल ब्राउज़र के हैंडऑफ़ को हैंडल करता है. ध्यान रखें कि जब उपयोगकर्ता किसी ब्राउज़ कैरसेल आइटम से इंटरैक्ट करेगा, तब माइक फिर से नहीं खुलेगा. इसलिए, आपको या तो बातचीत खत्म करनी चाहिए या ऊपर दिए गए दिशा-निर्देशों के मुताबिक, अपने जवाब में सुझाव देने वाले चिप शामिल करने चाहिए.

सुझाव वाले चिप

चौथी इमेज. सुझाव वाले चिप का उदाहरण (स्मार्टफ़ोन)

जवाबों पर संकेत देने के लिए, सुझाव वाले चिप का इस्तेमाल करके बातचीत को जारी रखें या उसमें बदलाव करें. अगर बातचीत के दौरान कार्रवाई करने के लिए कोई मुख्य कॉल है, तो उसे पहले सुझाव चिप के रूप में शामिल करें.

जब भी हो सके, आपको चैट बबल के हिस्से के तौर पर किसी एक अहम सुझाव को शामिल करना चाहिए. हालांकि, ऐसा सिर्फ़ तब करें, जब जवाब या चैट से बातचीत सामान्य लगे.

प्रॉपर्टी

सुझाव वाले चिप में यहां दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं. इन्हें कॉन्फ़िगर किया जा सकता है:

  • actions.capability.SCREEN_OUTPUT क्षमता वाले प्लैटफ़ॉर्म पर काम करती है.
  • वेब से सुझाव वाले चिप को लिंक करने के लिए, प्लैटफ़ॉर्म में actions.capability.WEB_BROWSER की सुविधा भी होनी चाहिए. फ़िलहाल, यह सुविधा स्मार्ट डिसप्ले पर उपलब्ध नहीं है.
  • ज़्यादा से ज़्यादा आठ चिप.
  • टेक्स्ट में ज़्यादा से ज़्यादा 25 वर्ण होने चाहिए.
  • सिर्फ़ सादा टेक्स्ट इस्तेमाल किया जा सकता है.

पांचवीं इमेज. सुझाव वाले चिप का उदाहरण (स्मार्ट डिसप्ले)

नमूना कोड

Node.js

app.intent('Suggestion Chips', (conv) => {
  if (!conv.screen) {
    conv.ask('Chips can be demonstrated on screen devices.');
    conv.ask('Which response would you like to see next?');
    return;
  }

  conv.ask('These are suggestion chips.');
  conv.ask(new Suggestions('Suggestion 1'));
  conv.ask(new Suggestions(['Suggestion 2', 'Suggestion 3']));
  conv.ask(new LinkOutSuggestion({
    name: 'Suggestion Link',
    url: 'https://assistant.google.com/',
  }));
  conv.ask('Which type of response would you like to see next?'); ;
});

Java

@ForIntent("Suggestion Chips")
public ActionResponse suggestionChips(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
    return responseBuilder
        .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
        .add("Which response would you like to see next?")
        .build();
  }

  responseBuilder
      .add("These are suggestion chips.")
      .addSuggestions(new String[] {"Suggestion 1", "Suggestion 2", "Suggestion 3"})
      .add(
          new LinkOutSuggestion()
              .setDestinationName("Suggestion Link")
              .setUrl("https://assistant.google.com/"))
      .add("Which type of response would you like to see next?");
  return responseBuilder.build();
}

Node.js

if (!conv.screen) {
  conv.ask('Chips can be demonstrated on screen devices.');
  conv.ask('Which response would you like to see next?');
  return;
}

conv.ask('These are suggestion chips.');
conv.ask(new Suggestions('Suggestion 1'));
conv.ask(new Suggestions(['Suggestion 2', 'Suggestion 3']));
conv.ask(new LinkOutSuggestion({
  name: 'Suggestion Link',
  url: 'https://assistant.google.com/',
}));
conv.ask('Which type of response would you like to see next?');

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
  return responseBuilder
      .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
      .add("Which response would you like to see next?")
      .build();
}

responseBuilder
    .add("These are suggestion chips.")
    .addSuggestions(new String[] {"Suggestion 1", "Suggestion 2", "Suggestion 3"})
    .add(
        new LinkOutSuggestion()
            .setDestinationName("Suggestion Link")
            .setUrl("https://assistant.google.com/"))
    .add("Which type of response would you like to see next?");
return responseBuilder.build();

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "These are suggestion chips."
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which type of response would you like to see next?"
            }
          }
        ],
        "suggestions": [
          {
            "title": "Suggestion 1"
          },
          {
            "title": "Suggestion 2"
          },
          {
            "title": "Suggestion 3"
          }
        ],
        "linkOutSuggestion": {
          "destinationName": "Suggestion Link",
          "url": "https://assistant.google.com/"
        }
      }
    }
  }
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "These are suggestion chips."
              }
            },
            {
              "simpleResponse": {
                "textToSpeech": "Which type of response would you like to see next?"
              }
            }
          ],
          "suggestions": [
            {
              "title": "Suggestion 1"
            },
            {
              "title": "Suggestion 2"
            },
            {
              "title": "Suggestion 3"
            }
          ],
          "linkOutSuggestion": {
            "destinationName": "Suggestion Link",
            "url": "https://assistant.google.com/"
          }
        }
      }
    }
  ]
}

मीडिया से जुड़े जवाब

छठी इमेज. मीडिया रिस्पॉन्स का उदाहरण (स्मार्टफ़ोन)

मीडिया से जुड़े रिस्पॉन्स की मदद से, आपकी कार्रवाइयों को एसएसएमएल की 240 सेकंड की सीमा से ज़्यादा देर तक ऑडियो कॉन्टेंट चलाने की सुविधा मिलती है. मीडिया से जुड़े जवाब का मुख्य कॉम्पोनेंट, सिंगल-ट्रैक कार्ड होता है. इस कार्ड की मदद से उपयोगकर्ता, ये काम कर सकते हैं:

  • पिछले 10 सेकंड फिर से चलाएं.
  • वीडियो को 30 सेकंड आगे बढ़ाएं.
  • मीडिया कॉन्टेंट की कुल अवधि देखें.
  • ऑडियो प्लेबैक की प्रोग्रेस इंडिकेटर देखें.
  • वीडियो चलाने में लगने वाला समय देखें.

मीडिया रिस्पॉन्स, वॉइस इंटरैक्शन के लिए इन ऑडियो कंट्रोल के साथ काम करते हैं:

  • “Ok Google, चलाओ.”
  • “Ok Google, रोको.”
  • “Ok Google, रुको.”
  • “Ok Google, फिर से शुरू करो.”

उपयोगकर्ता, "Ok Google, आवाज़ तेज़ करो " या "Ok Google, आवाज़ को 50 प्रतिशत पर सेट करो" जैसे वाक्यांशों का इस्तेमाल करके भी आवाज़ कंट्रोल कर सकते हैं." अगर आपकी कार्रवाई में सेट किए गए इंटेंट, ट्रेनिंग वाले मिलते-जुलते वाक्यांशों को हैंडल करते हैं, तो उन्हें प्राथमिकता दी जाएगी. अगर आपकी सेट की गई कार्रवाई में कोई खास वजह नहीं है, तो Assistant को उपयोगकर्ता के इन अनुरोधों को हैंडल करने की अनुमति दें.

प्रॉपर्टी

मीडिया जवाबों में नीचे दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं, जिन्हें आप कॉन्फ़िगर कर सकते हैं:

  • actions.capability.MEDIA_RESPONSE_AUDIO की क्षमता वाले प्लैटफ़ॉर्म पर काम करता है.
  • प्लेबैक के लिए, ऑडियो सही तरीके से फ़ॉर्मैट की गई .mp3 फ़ाइल में होना चाहिए. लाइव स्ट्रीमिंग की सुविधा उपलब्ध नहीं है.
  • वीडियो चलाने के लिए, मीडिया फ़ाइल को एचटीटीपीएस यूआरएल के तौर पर सबमिट करना ज़रूरी है.
  • इमेज (ज़रूरी नहीं)
    • आपके पास इमेज या आइकॉन शामिल करने का विकल्प भी होता है.
    • आइकॉन
      • आपका आइकॉन, मीडिया प्लेयर कार्ड की दाईं ओर, बॉर्डरलेस थंबनेल के तौर पर दिखता है.
      • साइज़ 36 x 36 dp होना चाहिए. बड़े साइज़ की इमेज का साइज़ बदल दिया जाता है, ताकि वे फ़िट हो सकें.
    • इमेज
      • इमेज कंटेनर की ऊंचाई 192 dp होगी.
      • आपकी इमेज, मीडिया प्लेयर कार्ड में सबसे ऊपर दिखती है और कार्ड की पूरी चौड़ाई तक फैली होती है. ज़्यादातर इमेज, ऊपर या किनारे पर बार के साथ दिखेंगी.
      • मोशन GIF की अनुमति है.
    • आपको इमेज के सोर्स को यूआरएल के तौर पर बताना होगा.
    • सभी इमेज पर वैकल्पिक टेक्स्ट डालना ज़रूरी है.

प्लैटफ़ॉर्म पर व्यवहार

मीडिया से जुड़े जवाब Android फ़ोन और Google Home पर काम करते हैं. मीडिया से मिलने वाले जवाबों का व्यवहार इस बात पर निर्भर करता है कि उपयोगकर्ता आपकी कार्रवाइयों के साथ किस तरह इंटरैक्ट करते हैं.

Android फ़ोन पर, इनमें से किसी भी शर्त के पूरा होने पर उपयोगकर्ता मीडिया प्रतिक्रियाएं देख सकते हैं:

  • Google Assistant फ़ोरग्राउंड में है और फ़ोन की स्क्रीन चालू है.
  • ऑडियो चलने के दौरान उपयोगकर्ता Google Assistant से चला जाता है. वह वीडियो पूरा होने के 10 मिनट के अंदर, Google Assistant पर वापस आ जाता है. Google Assistant पर लौटने पर, उपयोगकर्ता को मीडिया कार्ड और सुझाव वाले चिप दिखते हैं.
  • Assistant, उपयोगकर्ताओं को आपकी बातचीत में, डिवाइस की आवाज़ कंट्रोल करने की सुविधा देती है. इसके लिए, वे "आवाज़ बढ़ाओ" या "आवाज़ को 50 प्रतिशत पर सेट करो" जैसे निर्देश देती हैं. अगर आपके ऐसे इंटेंट हैं जो मिलते-जुलते ट्रेनिंग वाले वाक्यांशों को हैंडल करते हैं, तो आपके इंटेंट को अहमियत दी जाएगी. हमारा सुझाव है कि जब तक आपकी सेट की गई कार्रवाई को करने की कोई खास वजह न हो, तब तक Assistant को उपयोगकर्ता के इन अनुरोधों का जवाब देने की अनुमति दें.

फ़ोन के लॉक होने पर, मीडिया कंट्रोल की सुविधा उपलब्ध होती है. Android पर, नियंत्रण सूचना क्षेत्र में भी दिखाई देते हैं.

सातवीं इमेज. मीडिया रिस्पॉन्स का उदाहरण (स्मार्ट डिसप्ले)

नमूना कोड

यहां दिए गए कोड सैंपल से पता चलता है कि मीडिया को शामिल करने के लिए, बेहतर रिस्पॉन्स को कैसे अपडेट किया जा सकता है.

Node.js

app.intent('Media Response', (conv) => {
  if (!conv.surface.capabilities
    .has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
      conv.ask('Sorry, this device does not support audio playback.');
      conv.ask('Which response would you like to see next?');
      return;
  }

  conv.ask('This is a media response example.');
  conv.ask(new MediaObject({
    name: 'Jazz in Paris',
    url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
    description: 'A funky Jazz tune',
    icon: new Image({
      url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
      alt: 'Album cover of an ocean view',
    }),
  }));
  conv.ask(new Suggestions(['Basic Card', 'List',
    'Carousel', 'Browsing Carousel']));
});

Java

@ForIntent("Media Response")
public ActionResponse mediaResponse(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.MEDIA_RESPONSE_AUDIO.getValue())) {
    return responseBuilder
        .add("Sorry, this device does not support audio playback.")
        .add("Which response would you like to see next?")
        .build();
  }

  responseBuilder
      .add("This is a media response example.")
      .add(
          new MediaResponse()
              .setMediaObjects(
                  new ArrayList<MediaObject>(
                      Arrays.asList(
                          new MediaObject()
                              .setName("Jazz in Paris")
                              .setDescription("A funky Jazz tune")
                              .setContentUrl(
                                  "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3")
                              .setIcon(
                                  new Image()
                                      .setUrl(
                                          "https://storage.googleapis.com/automotive-media/album_art.jpg")
                                      .setAccessibilityText("Album cover of an ocean view")))))
              .setMediaType("AUDIO"))
      .addSuggestions(new String[] {"Basic Card", "List", "Carousel", "Browsing Carousel"});
  return responseBuilder.build();
}

Node.js

if (!conv.surface.capabilities
  .has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
    conv.ask('Sorry, this device does not support audio playback.');
    conv.ask('Which response would you like to see next?');
    return;
}

conv.ask('This is a media response example.');
conv.ask(new MediaObject({
  name: 'Jazz in Paris',
  url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
  description: 'A funky Jazz tune',
  icon: new Image({
    url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
    alt: 'Album cover of an ocean view',
  }),
}));
conv.ask(new Suggestions(['Basic Card', 'List',
  'Carousel', 'Browsing Carousel']));

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.MEDIA_RESPONSE_AUDIO.getValue())) {
  return responseBuilder
      .add("Sorry, this device does not support audio playback.")
      .add("Which response would you like to see next?")
      .build();
}

responseBuilder
    .add("This is a media response example.")
    .add(
        new MediaResponse()
            .setMediaObjects(
                new ArrayList<MediaObject>(
                    Arrays.asList(
                        new MediaObject()
                            .setName("Jazz in Paris")
                            .setDescription("A funky Jazz tune")
                            .setContentUrl(
                                "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3")
                            .setIcon(
                                new Image()
                                    .setUrl(
                                        "https://storage.googleapis.com/automotive-media/album_art.jpg")
                                    .setAccessibilityText("Album cover of an ocean view")))))
            .setMediaType("AUDIO"))
    .addSuggestions(new String[] {"Basic Card", "List", "Carousel", "Browsing Carousel"});
return responseBuilder.build();

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "This is a media response example."
            }
          },
          {
            "mediaResponse": {
              "mediaType": "AUDIO",
              "mediaObjects": [
                {
                  "contentUrl": "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3",
                  "description": "A funky Jazz tune",
                  "icon": {
                    "url": "https://storage.googleapis.com/automotive-media/album_art.jpg",
                    "accessibilityText": "Album cover of an ocean view"
                  },
                  "name": "Jazz in Paris"
                }
              ]
            }
          }
        ],
        "suggestions": [
          {
            "title": "Basic Card"
          },
          {
            "title": "List"
          },
          {
            "title": "Carousel"
          },
          {
            "title": "Browsing Carousel"
          }
        ]
      }
    }
  }
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "This is a media response example."
              }
            },
            {
              "mediaResponse": {
                "mediaType": "AUDIO",
                "mediaObjects": [
                  {
                    "contentUrl": "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3",
                    "description": "A funky Jazz tune",
                    "icon": {
                      "url": "https://storage.googleapis.com/automotive-media/album_art.jpg",
                      "accessibilityText": "Album cover of an ocean view"
                    },
                    "name": "Jazz in Paris"
                  }
                ]
              }
            }
          ],
          "suggestions": [
            {
              "title": "Basic Card"
            },
            {
              "title": "List"
            },
            {
              "title": "Carousel"
            },
            {
              "title": "Browsing Carousel"
            }
          ]
        }
      }
    }
  ]
}

दिशा-निर्देश

आपके जवाब में AUDIO के mediaType के साथ mediaResponse और रिच रिस्पॉन्स के आइटम कलेक्शन में mediaObject शामिल होना चाहिए. मीडिया रिस्पॉन्स, एक मीडिया ऑब्जेक्ट के साथ काम करता है. मीडिया ऑब्जेक्ट में ऑडियो फ़ाइल के कॉन्टेंट का यूआरएल शामिल होना चाहिए. मीडिया ऑब्जेक्ट में नाम, सब-टेक्स्ट (ब्यौरा), और आइकॉन या इमेज का यूआरएल भी शामिल हो सकता है.

फ़ोन और Google Home पर, जब आपकी सेट की गई कार्रवाई में ऑडियो चल जाता है, तो Google Assistant यह जांच करती है कि मीडिया से मिला जवाब FinalResponse है या नहीं. अगर ऐसा नहीं है, तो यह टीम को भेजे गए आइटम के लिए कॉलबैक भेजता है. इससे उपयोगकर्ता को जवाब दिया जा सकता है.

अगर जवाब FinalResponse नहीं है, तो आपकी सेट की गई कार्रवाई में सुझाव देने वाले चिप शामिल होने चाहिए.

प्लेबैक पूरा होने के बाद कॉलबैक को हैंडल करना

आपकी सेट की गई कार्रवाई को actions.intent.MEDIA_STATUS इंटेंट को हैंडल करना चाहिए, ताकि उपयोगकर्ता को फ़ॉलो-अप के लिए निर्देश दिया जा सके (जैसे, कोई दूसरा गाना चलाने के लिए). मीडिया प्लेबैक पूरा होने पर, आपकी सेट की गई कार्रवाई को यह कॉलबैक मिलता है. कॉलबैक में, MEDIA_STATUS आर्ग्युमेंट में, मौजूदा मीडिया के स्टेटस की जानकारी होती है. स्टेटस वैल्यू या तो FINISHED या STATUS_UNSPECIFIED होगी.

Dialogflow का इस्तेमाल किया जा रहा है

अगर आपको Dialogflow में बातचीत वाली ब्रांचिंग करनी है, तो आपको इंटेंट पर actions_capability_media_response_audio का इनपुट कॉन्टेक्स्ट सेट अप करना होगा. इससे यह पक्का किया जा सकेगा कि यह सिर्फ़ उन प्लैटफ़ॉर्म पर ट्रिगर हो जो मीडिया रिस्पॉन्स के साथ काम करते हैं.

आपके लक्ष्य को पूरा करना

नीचे दिया गया कोड स्निपेट दिखाता है कि अपनी कार्रवाई के लिए, फ़ुलफ़िलमेंट कोड कैसे लिखा जा सकता है. अगर Dialogflow का इस्तेमाल किया जा रहा है, तो actions.intent.MEDIA_STATUS को actions_intent_MEDIA_STATUS इवेंट पाने वाले इंटेंट में तय की गई कार्रवाई के नाम से बदलें, जैसे कि "media.status.update".

Node.js

app.intent('Media Status', (conv) => {
  const mediaStatus = conv.arguments.get('MEDIA_STATUS');
  let response = 'Unknown media status received.';
  if (mediaStatus && mediaStatus.status === 'FINISHED') {
    response = 'Hope you enjoyed the tune!';
  }
  conv.ask(response);
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("Media Status")
public ActionResponse mediaStatus(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  String mediaStatus = request.getMediaStatus();
  String response = "Unknown media status received.";
  if (mediaStatus != null && mediaStatus.equals("FINISHED")) {
    response = "Hope you enjoyed the tune!";
  }
  responseBuilder.add(response);
  responseBuilder.add("Which response would you like to see next?");
  return responseBuilder.build();
}

Node.js

app.intent('actions.intent.MEDIA_STATUS', (conv) => {
  const mediaStatus = conv.arguments.get('MEDIA_STATUS');
  let response = 'Unknown media status received.';
  if (mediaStatus && mediaStatus.status === 'FINISHED') {
    response = 'Hope you enjoyed the tune!';
  }
  conv.ask(response);
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("actions.intent.MEDIA_STATUS")
public ActionResponse mediaStatus(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  String mediaStatus = request.getMediaStatus();
  String response = "Unknown media status received.";
  if (mediaStatus != null && mediaStatus.equals("FINISHED")) {
    response = "Hope you enjoyed the tune!";
  }
  responseBuilder.add(response);
  responseBuilder.add("Which response would you like to see next?");
  return responseBuilder.build();
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक अनुरोध के बारे में बताता है.

{
  "responseId": "151b68df-98de-41fb-94b5-caeace90a7e9-21947381",
  "queryResult": {
    "queryText": "actions_intent_MEDIA_STATUS",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Webhook failed for intent: Media Status",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "Webhook failed for intent: Media Status"
          ]
        }
      }
    ],
    "outputContexts": [
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_capability_media_response_audio"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_capability_account_linking"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_capability_web_browser"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_capability_screen_output"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_capability_audio_output"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/google_assistant_input_type_voice"
      },
      {
        "name": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA/contexts/actions_intent_media_status",
        "parameters": {
          "MEDIA_STATUS": {
            "@type": "type.googleapis.com/google.actions.v2.MediaStatus",
            "status": "FINISHED"
          }
        }
      }
    ],
    "intent": {
      "name": "projects/df-responses-kohler/agent/intents/068b27d3-c148-4044-bfab-dfa37eebd90d",
      "displayName": "Media Status"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "en"
  },
  "originalDetectIntentRequest": {
    "source": "google",
    "version": "2",
    "payload": {
      "user": {
        "locale": "en-US",
        "lastSeen": "2019-08-04T23:57:15Z",
        "userVerificationStatus": "VERIFIED"
      },
      "conversation": {
        "conversationId": "ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA",
        "type": "ACTIVE",
        "conversationToken": "[]"
      },
      "inputs": [
        {
          "intent": "actions.intent.MEDIA_STATUS",
          "rawInputs": [
            {
              "inputType": "VOICE"
            }
          ],
          "arguments": [
            {
              "name": "MEDIA_STATUS",
              "extension": {
                "@type": "type.googleapis.com/google.actions.v2.MediaStatus",
                "status": "FINISHED"
              }
            }
          ]
        }
      ],
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
          },
          {
            "name": "actions.capability.ACCOUNT_LINKING"
          },
          {
            "name": "actions.capability.WEB_BROWSER"
          },
          {
            "name": "actions.capability.SCREEN_OUTPUT"
          },
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          }
        ]
      },
      "isInSandbox": true,
      "availableSurfaces": [
        {
          "capabilities": [
            {
              "name": "actions.capability.WEB_BROWSER"
            },
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            },
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            }
          ]
        }
      ],
      "requestType": "SIMULATOR"
    }
  },
  "session": "projects/df-responses-kohler/agent/sessions/ABwppHHsebncupHK11oKhsCTgyH96GRNYH-xpeeMTqb-cvOxbd67QenbRlZM4bGAIB8_KXdTfI7-7lYVKN1ovAhCaA"
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक अनुरोध के बारे में बताता है.

{
  "user": {
    "locale": "en-US",
    "lastSeen": "2019-08-06T07:38:40Z",
    "userVerificationStatus": "VERIFIED"
  },
  "conversation": {
    "conversationId": "ABwppHGcqunXh1M6IE0lu2sVqXdpJfdpC5FWMkMSXQskK1nzb4IkSUSRqQzoEr0Ly0z_G3mwyZlk5rFtd1w",
    "type": "NEW"
  },
  "inputs": [
    {
      "intent": "actions.intent.MEDIA_STATUS",
      "rawInputs": [
        {
          "inputType": "VOICE"
        }
      ],
      "arguments": [
        {
          "name": "MEDIA_STATUS",
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.MediaStatus",
            "status": "FINISHED"
          }
        }
      ]
    }
  ],
  "surface": {
    "capabilities": [
      {
        "name": "actions.capability.SCREEN_OUTPUT"
      },
      {
        "name": "actions.capability.WEB_BROWSER"
      },
      {
        "name": "actions.capability.AUDIO_OUTPUT"
      },
      {
        "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
      },
      {
        "name": "actions.capability.ACCOUNT_LINKING"
      }
    ]
  },
  "isInSandbox": true,
  "availableSurfaces": [
    {
      "capabilities": [
        {
          "name": "actions.capability.WEB_BROWSER"
        },
        {
          "name": "actions.capability.AUDIO_OUTPUT"
        },
        {
          "name": "actions.capability.SCREEN_OUTPUT"
        }
      ]
    }
  ],
  "requestType": "SIMULATOR"
}

टेबल कार्ड

टेबल कार्ड की मदद से, अपने जवाब में टेबल के फ़ॉर्मैट में डेटा दिखाया जा सकता है. जैसे, खेल की स्थिति, चुनाव के नतीजे, और फ़्लाइट. आप ऐसे कॉलम और पंक्तियां (हर एक तक ज़्यादा से ज़्यादा तीन) तय कर सकते हैं जिन्हें आपके टेबल कार्ड में दिखाने के लिए Assistant की ज़रूरत होगी. आपके पास अतिरिक्त कॉलम और पंक्तियों को उनकी प्राथमिकता के साथ तय करने का विकल्प भी है.

टेबल, वर्टिकल सूचियों से अलग होती हैं, क्योंकि टेबल स्थिर डेटा दिखाती हैं और उनसे इंटरैक्ट नहीं किया जा सकता, जैसे सूची के एलिमेंट.

आठवीं इमेज. टेबल कार्ड का उदाहरण (स्मार्ट डिसप्ले)

प्रॉपर्टी

टेबल कार्ड में नीचे दी गई ज़रूरी शर्तें और वैकल्पिक प्रॉपर्टी होती हैं, जिन्हें आप कॉन्फ़िगर कर सकते हैं:

  • actions.capability.SCREEN_OUTPUT क्षमता वाले प्लैटफ़ॉर्म पर काम करती है.

इस सेक्शन में खास जानकारी दी गई है कि टेबल कार्ड में एलिमेंट को पसंद के मुताबिक कैसे बनाया जा सकता है.

नाम वैकल्पिक है कस्टमाइज़ करने योग्य है कस्टमाइज़ेशन से जुड़े नोट
title हां हां टेबल का पूरा टाइटल. अगर सबटाइटल सेट है, तो इसे सेट करना ज़रूरी है. आपके पास फ़ॉन्ट फ़ैमिली और रंग को पसंद के मुताबिक बनाने का विकल्प है.
subtitle हां नहीं टेबल के लिए सबटाइटल.
image हां हां टेबल से जुड़ी इमेज.
Row नहीं हां

टेबल की लाइन का डेटा. इसमें Cell ऑब्जेक्ट का कलेक्शन और divider_after प्रॉपर्टी होती है. इससे पता चलता है कि लाइन के बाद कोई डिवाइडर होना चाहिए या नहीं.

इस बात की गारंटी है कि पहली तीन लाइनें ही दिखेंगी. हालांकि, हो सकता है कि अन्य लाइनें कुछ प्लैटफ़ॉर्म पर न दिखें.

कृपया सिम्युलेटर की मदद से जांच करके देखें कि दिए गए प्लैटफ़ॉर्म के लिए कौनसी लाइनें दिख रही हैं. WEB_BROWSER की सुविधा के साथ काम करने वाले प्लैटफ़ॉर्म पर, उपयोगकर्ता को ज़्यादा डेटा वाले वेब पेज पर भेजा जा सकता है. फ़िलहाल, स्मार्ट डिसप्ले पर वेब से लिंक करने की सुविधा उपलब्ध नहीं है.

ColumnProperties हां हां किसी कॉलम का हेडर और अलाइनमेंट. इसमें header प्रॉपर्टी (कॉलम के लिए हेडर टेक्स्ट को दिखाने वाली) और horizontal_alignment प्रॉपर्टी (HorizontalAlignment टाइप की) होनी चाहिए.
Cell नहीं हां किसी पंक्ति में मौजूद सेल के बारे में बताता है. हर सेल में एक स्ट्रिंग होती है, जो टेक्स्ट की वैल्यू दिखाती है. सेल का टेक्स्ट अपनी पसंद के मुताबिक बदला जा सकता है.
Button हां हां एक बटन ऑब्जेक्ट, जो आम तौर पर कार्ड के नीचे दिखता है. टेबल कार्ड में सिर्फ़ एक बटन हो सकता है. बटन के रंग को अपनी पसंद के मुताबिक बनाया जा सकता है.
HorizontalAlignment हां हां सेल के अंदर कॉन्टेंट का हॉरिज़ॉन्टल अलाइनमेंट. वैल्यू LEADING, CENTER या TRAILING हो सकती है. अगर इसकी जानकारी नहीं दी गई है, तो कॉन्टेंट को सेल के अगले किनारे पर अलाइन किया जाता है.

नमूना कोड

नीचे दिए गए स्निपेट से, आसान टेबल कार्ड को लागू करने का तरीका पता चलता है:

Node.js

app.intent('Simple Table Card', (conv) => {
  if (!conv.screen) {
    conv.ask('Sorry, try this on a screen device or select the ' +
      'phone surface in the simulator.');
    conv.ask('Which response would you like to see next?');
    return;
  }

  conv.ask('This is a simple table example.');
  conv.ask(new Table({
    dividers: true,
    columns: ['header 1', 'header 2', 'header 3'],
    rows: [
      ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
      ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
    ],
  }));
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("Simple Table Card")
public ActionResponse simpleTable(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
    return responseBuilder
        .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
        .add("Which response would you like to see next?")
        .build();
  }

  responseBuilder
      .add("This is a simple table example.")
      .add(
          new TableCard()
              .setColumnProperties(
                  Arrays.asList(
                      new TableCardColumnProperties().setHeader("header 1"),
                      new TableCardColumnProperties().setHeader("header 2"),
                      new TableCardColumnProperties().setHeader("header 3")))
              .setRows(
                  Arrays.asList(
                      new TableCardRow()
                          .setCells(
                              Arrays.asList(
                                  new TableCardCell().setText("row 1 item 1"),
                                  new TableCardCell().setText("row 1 item 2"),
                                  new TableCardCell().setText("row 1 item 3"))),
                      new TableCardRow()
                          .setCells(
                              Arrays.asList(
                                  new TableCardCell().setText("row 2 item 1"),
                                  new TableCardCell().setText("row 2 item 2"),
                                  new TableCardCell().setText("row 2 item 3"))))));
  return responseBuilder.build();
}

Node.js

if (!conv.screen) {
  conv.ask('Sorry, try this on a screen device or select the ' +
    'phone surface in the simulator.');
  conv.ask('Which response would you like to see next?');
  return;
}

conv.ask('This is a simple table example.');
conv.ask(new Table({
  dividers: true,
  columns: ['header 1', 'header 2', 'header 3'],
  rows: [
    ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
    ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
  ],
}));
conv.ask('Which response would you like to see next?');

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
  return responseBuilder
      .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
      .add("Which response would you like to see next?")
      .build();
}

responseBuilder
    .add("This is a simple table example.")
    .add(
        new TableCard()
            .setColumnProperties(
                Arrays.asList(
                    new TableCardColumnProperties().setHeader("header 1"),
                    new TableCardColumnProperties().setHeader("header 2"),
                    new TableCardColumnProperties().setHeader("header 3")))
            .setRows(
                Arrays.asList(
                    new TableCardRow()
                        .setCells(
                            Arrays.asList(
                                new TableCardCell().setText("row 1 item 1"),
                                new TableCardCell().setText("row 1 item 2"),
                                new TableCardCell().setText("row 1 item 3"))),
                    new TableCardRow()
                        .setCells(
                            Arrays.asList(
                                new TableCardCell().setText("row 2 item 1"),
                                new TableCardCell().setText("row 2 item 2"),
                                new TableCardCell().setText("row 2 item 3"))))));
return responseBuilder.build();

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "This is a simple table example."
            }
          },
          {
            "tableCard": {
              "rows": [
                {
                  "cells": [
                    {
                      "text": "row 1 item 1"
                    },
                    {
                      "text": "row 1 item 2"
                    },
                    {
                      "text": "row 1 item 3"
                    }
                  ],
                  "dividerAfter": true
                },
                {
                  "cells": [
                    {
                      "text": "row 2 item 1"
                    },
                    {
                      "text": "row 2 item 2"
                    },
                    {
                      "text": "row 2 item 3"
                    }
                  ],
                  "dividerAfter": true
                }
              ],
              "columnProperties": [
                {
                  "header": "header 1"
                },
                {
                  "header": "header 2"
                },
                {
                  "header": "header 3"
                }
              ]
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which response would you like to see next?"
            }
          }
        ]
      }
    }
  }
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "This is a simple table example."
              }
            },
            {
              "tableCard": {
                "columnProperties": [
                  {
                    "header": "header 1"
                  },
                  {
                    "header": "header 2"
                  },
                  {
                    "header": "header 3"
                  }
                ],
                "rows": [
                  {
                    "cells": [
                      {
                        "text": "row 1 item 1"
                      },
                      {
                        "text": "row 1 item 2"
                      },
                      {
                        "text": "row 1 item 3"
                      }
                    ],
                    "dividerAfter": true
                  },
                  {
                    "cells": [
                      {
                        "text": "row 2 item 1"
                      },
                      {
                        "text": "row 2 item 2"
                      },
                      {
                        "text": "row 2 item 3"
                      }
                    ],
                    "dividerAfter": true
                  }
                ]
              }
            },
            {
              "simpleResponse": {
                "textToSpeech": "Which response would you like to see next?"
              }
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ]
    }
  ]
}

नीचे दिए गए स्निपेट, कॉम्प्लेक्स टेबल कार्ड को लागू करने का तरीका बताते हैं:

Node.js

app.intent('Advanced Table Card', (conv) => {
  if (!conv.screen) {
    conv.ask('Sorry, try this on a screen device or select the ' +
      'phone surface in the simulator.');
    conv.ask('Which response would you like to see next?');
    return;
  }

  conv.ask('This is a table with all the possible fields.');
  conv.ask(new Table({
    title: 'Table Title',
    subtitle: 'Table Subtitle',
    image: new Image({
      url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
      alt: 'Alt Text',
    }),
    columns: [
      {
        header: 'header 1',
        align: 'CENTER',
      },
      {
        header: 'header 2',
        align: 'LEADING',
      },
      {
        header: 'header 3',
        align: 'TRAILING',
      },
    ],
    rows: [
      {
        cells: ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
        dividerAfter: false,
      },
      {
        cells: ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
        dividerAfter: true,
      },
      {
        cells: ['row 3 item 1', 'row 3 item 2', 'row 3 item 3'],
      },
    ],
    buttons: new Button({
      title: 'Button Text',
      url: 'https://assistant.google.com',
    }),
  }));
  conv.ask('Which response would you like to see next?');
});

Java

@ForIntent("Advanced Table Card")
public ActionResponse advancedTable(ActionRequest request) {
  ResponseBuilder responseBuilder = getResponseBuilder(request);
  if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
    return responseBuilder
        .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
        .add("Which response would you like to see next?")
        .build();
  }

  responseBuilder
      .add("This is a table with all the possible fields.")
      .add(
          new TableCard()
              .setTitle("Table Title")
              .setSubtitle("Table Subtitle")
              .setImage(
                  new Image()
                      .setUrl(
                          "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                      .setAccessibilityText("Alt text"))
              .setButtons(
                  Arrays.asList(
                      new Button()
                          .setTitle("Button Text")
                          .setOpenUrlAction(
                              new OpenUrlAction().setUrl("https://assistant.google.com"))))
              .setColumnProperties(
                  Arrays.asList(
                      new TableCardColumnProperties()
                          .setHeader("header 1")
                          .setHorizontalAlignment("CENTER"),
                      new TableCardColumnProperties()
                          .setHeader("header 2")
                          .setHorizontalAlignment("LEADING"),
                      new TableCardColumnProperties()
                          .setHeader("header 3")
                          .setHorizontalAlignment("TRAILING")))
              .setRows(
                  Arrays.asList(
                      new TableCardRow()
                          .setCells(
                              Arrays.asList(
                                  new TableCardCell().setText("row 1 item 1"),
                                  new TableCardCell().setText("row 1 item 2"),
                                  new TableCardCell().setText("row 1 item 3")))
                          .setDividerAfter(false),
                      new TableCardRow()
                          .setCells(
                              Arrays.asList(
                                  new TableCardCell().setText("row 2 item 1"),
                                  new TableCardCell().setText("row 2 item 2"),
                                  new TableCardCell().setText("row 2 item 3")))
                          .setDividerAfter(true),
                      new TableCardRow()
                          .setCells(
                              Arrays.asList(
                                  new TableCardCell().setText("row 2 item 1"),
                                  new TableCardCell().setText("row 2 item 2"),
                                  new TableCardCell().setText("row 2 item 3"))))));
  return responseBuilder.build();
}

Node.js

if (!conv.screen) {
  conv.ask('Sorry, try this on a screen device or select the ' +
    'phone surface in the simulator.');
  conv.ask('Which response would you like to see next?');
  return;
}

conv.ask('This is a table with all the possible fields.');
conv.ask(new Table({
  title: 'Table Title',
  subtitle: 'Table Subtitle',
  image: new Image({
    url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
    alt: 'Alt Text',
  }),
  columns: [
    {
      header: 'header 1',
      align: 'CENTER',
    },
    {
      header: 'header 2',
      align: 'LEADING',
    },
    {
      header: 'header 3',
      align: 'TRAILING',
    },
  ],
  rows: [
    {
      cells: ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
      dividerAfter: false,
    },
    {
      cells: ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
      dividerAfter: true,
    },
    {
      cells: ['row 3 item 1', 'row 3 item 2', 'row 3 item 3'],
    },
  ],
  buttons: new Button({
    title: 'Button Text',
    url: 'https://assistant.google.com',
  }),
}));
conv.ask('Which response would you like to see next?');

Java

ResponseBuilder responseBuilder = getResponseBuilder(request);
if (!request.hasCapability(Capability.SCREEN_OUTPUT.getValue())) {
  return responseBuilder
      .add("Sorry, try ths on a screen device or select the phone surface in the simulator.")
      .add("Which response would you like to see next?")
      .build();
}

responseBuilder
    .add("This is a table with all the possible fields.")
    .add(
        new TableCard()
            .setTitle("Table Title")
            .setSubtitle("Table Subtitle")
            .setImage(
                new Image()
                    .setUrl(
                        "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png")
                    .setAccessibilityText("Alt text"))
            .setButtons(
                Arrays.asList(
                    new Button()
                        .setTitle("Button Text")
                        .setOpenUrlAction(
                            new OpenUrlAction().setUrl("https://assistant.google.com"))))
            .setColumnProperties(
                Arrays.asList(
                    new TableCardColumnProperties()
                        .setHeader("header 1")
                        .setHorizontalAlignment("CENTER"),
                    new TableCardColumnProperties()
                        .setHeader("header 2")
                        .setHorizontalAlignment("LEADING"),
                    new TableCardColumnProperties()
                        .setHeader("header 3")
                        .setHorizontalAlignment("TRAILING")))
            .setRows(
                Arrays.asList(
                    new TableCardRow()
                        .setCells(
                            Arrays.asList(
                                new TableCardCell().setText("row 1 item 1"),
                                new TableCardCell().setText("row 1 item 2"),
                                new TableCardCell().setText("row 1 item 3")))
                        .setDividerAfter(false),
                    new TableCardRow()
                        .setCells(
                            Arrays.asList(
                                new TableCardCell().setText("row 2 item 1"),
                                new TableCardCell().setText("row 2 item 2"),
                                new TableCardCell().setText("row 2 item 3")))
                        .setDividerAfter(true),
                    new TableCardRow()
                        .setCells(
                            Arrays.asList(
                                new TableCardCell().setText("row 2 item 1"),
                                new TableCardCell().setText("row 2 item 2"),
                                new TableCardCell().setText("row 2 item 3"))))));
return responseBuilder.build();

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "This is a table with all the possible fields."
            }
          },
          {
            "tableCard": {
              "title": "Table Title",
              "subtitle": "Table Subtitle",
              "image": {
                "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                "accessibilityText": "Alt Text"
              },
              "rows": [
                {
                  "cells": [
                    {
                      "text": "row 1 item 1"
                    },
                    {
                      "text": "row 1 item 2"
                    },
                    {
                      "text": "row 1 item 3"
                    }
                  ],
                  "dividerAfter": false
                },
                {
                  "cells": [
                    {
                      "text": "row 2 item 1"
                    },
                    {
                      "text": "row 2 item 2"
                    },
                    {
                      "text": "row 2 item 3"
                    }
                  ],
                  "dividerAfter": true
                },
                {
                  "cells": [
                    {
                      "text": "row 3 item 1"
                    },
                    {
                      "text": "row 3 item 2"
                    },
                    {
                      "text": "row 3 item 3"
                    }
                  ]
                }
              ],
              "columnProperties": [
                {
                  "header": "header 1",
                  "horizontalAlignment": "CENTER"
                },
                {
                  "header": "header 2",
                  "horizontalAlignment": "LEADING"
                },
                {
                  "header": "header 3",
                  "horizontalAlignment": "TRAILING"
                }
              ],
              "buttons": [
                {
                  "title": "Button Text",
                  "openUrlAction": {
                    "url": "https://assistant.google.com"
                  }
                }
              ]
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Which response would you like to see next?"
            }
          }
        ]
      }
    }
  }
}

JSON

ध्यान दें कि नीचे दिया गया JSON, वेबहुक रिस्पॉन्स के बारे में बताता है.

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ],
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "This is a table with all the possible fields."
              }
            },
            {
              "tableCard": {
                "title": "Table Title",
                "subtitle": "Table Subtitle",
                "image": {
                  "url": "https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png",
                  "accessibilityText": "Alt Text"
                },
                "rows": [
                  {
                    "cells": [
                      {
                        "text": "row 1 item 1"
                      },
                      {
                        "text": "row 1 item 2"
                      },
                      {
                        "text": "row 1 item 3"
                      }
                    ],
                    "dividerAfter": false
                  },
                  {
                    "cells": [
                      {
                        "text": "row 2 item 1"
                      },
                      {
                        "text": "row 2 item 2"
                      },
                      {
                        "text": "row 2 item 3"
                      }
                    ],
                    "dividerAfter": true
                  },
                  {
                    "cells": [
                      {
                        "text": "row 3 item 1"
                      },
                      {
                        "text": "row 3 item 2"
                      },
                      {
                        "text": "row 3 item 3"
                      }
                    ]
                  }
                ],
                "columnProperties": [
                  {
                    "header": "header 1",
                    "horizontalAlignment": "CENTER"
                  },
                  {
                    "header": "header 2",
                    "horizontalAlignment": "LEADING"
                  },
                  {
                    "header": "header 3",
                    "horizontalAlignment": "TRAILING"
                  }
                ],
                "buttons": [
                  {
                    "title": "Button Text",
                    "openUrlAction": {
                      "url": "https://assistant.google.com"
                    }
                  }
                ]
              }
            },
            {
              "simpleResponse": {
                "textToSpeech": "Which response would you like to see next?"
              }
            }
          ]
        }
      }
    }
  ]
}

अपने जवाबों को पसंद के मुताबिक़ बनाना

पसंद के मुताबिक थीम बनाकर, रिच जवाबों के दिखने का तरीका बदला जा सकता है. अगर आप अपने Actions प्रोजेक्ट के लिए कोई थीम तय करते हैं, तो आपके प्रोजेक्ट की कार्रवाइयों के लिए रिच जवाबों को आपकी थीम के मुताबिक स्टाइल किया जाएगा. जब उपयोगकर्ता स्क्रीन वाली सतह पर आपकी कार्रवाइयों को शुरू करते हैं, तब कस्टम ब्रैंडिंग की मदद से बातचीत का अलग लुक और स्टाइल तय किया जा सकता है.

पसंद के मुताबिक जवाब थीम सेट करने के लिए, ये काम करें:

  1. Actions कंसोल में, डेवलप करें > थीम को पसंद के मुताबिक बनाना पर जाएं.
  2. इनमें से किसी एक या सभी को सेट करें:
    • बैकग्राउंड का रंग, जिसे आपके कार्ड के बैकग्राउंड के तौर पर इस्तेमाल किया जा सके. आम तौर पर, आपको बैकग्राउंड के लिए हल्के रंग का इस्तेमाल करना चाहिए, ताकि कार्ड के कॉन्टेंट को आसानी से पढ़ा जा सके.
    • प्राइमरी कलर, आपके कार्ड के हेडर टेक्स्ट और यूज़र इंटरफ़ेस (यूआई) एलिमेंट का मुख्य रंग होता है. आम तौर पर, आपको बैकग्राउंड के साथ कंट्रास्ट के लिए गहरे मुख्य रंग का इस्तेमाल करना चाहिए.
    • फ़ॉन्ट फ़ैमिली में टाइटल और दूसरे मुख्य टेक्स्ट एलिमेंट के लिए इस्तेमाल किए गए फ़ॉन्ट के टाइप के बारे में बताया गया है.
    • इमेज के कोने की स्टाइल, आपके कार्ड के कोनों के रंग को बदल सकती है.
    • बैकग्राउंड इमेज में बैकग्राउंड के रंग की जगह अपनी पसंद के मुताबिक बनाई गई इमेज का इस्तेमाल किया जाता है. जब सरफ़ेस डिवाइस लैंडस्केप या पोर्ट्रेट मोड में हो, तो आपको दो अलग-अलग इमेज देनी होंगी. ध्यान दें कि अगर बैकग्राउंड इमेज का इस्तेमाल किया जाता है, तो मुख्य रंग सफ़ेद पर सेट होता है.
  3. सेव करें पर क्लिक करें.
नौवीं इमेज. Actions कंसोल में थीम को पसंद के मुताबिक बनाना