Как я могу создать Action на Google, используя Dialogflow на основе карты Basic и привязанный к веб-сайту? - PullRequest
0 голосов
/ 03 марта 2019

Я Анналх Шейх из Индии.Недавно я стал членом сообщества разработчиков Google Assistant.Сейчас я работаю в приложении для изображения и факта дня, который связан с сайтом.И я строю это с помощью Dialogflow.Я хочу знать, как я мог бы создать приложение Assistant на основе базового отклика карты, связанного с веб-сайтом NASA Apod. Это должно быть как приложение фактического изображения дня.Пожалуйста, дайте мне решение.

1 Ответ

0 голосов
/ 05 марта 2019

Доброе утро, Annalhq!Вы можете использовать этот пример кода, чтобы начать работу с базовой картой:

if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
  conv.ask('Sorry, try this on a screen device or select the ' +
    'phone surface in the simulator.');
  return;
}

conv.ask('This is a basic card example.');
// Create 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 emoji ?.  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://example.com/image.png',
    alt: 'Image alternate text',
  }),
  display: 'CROPPED',
}));

После того, как ваша карта отобразится в соответствии с назначением, вы можете добавить ссылку чипов предложения, например:

if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
  conv.ask('Sorry, try this on a screen device or select the ' +
    'phone surface in the simulator.');
  return;
}

conv.ask('These are suggestion chips.');
conv.ask(new Suggestions('Suggestion Chips'));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
conv.ask(new LinkOutSuggestion({
  name: 'Suggestion Link',
  url: 'https://assistant.google.com/',
}));

Длядополнительную информацию см. в документах:

https://developers.google.com/actions/assistant/responses#basic_card

https://developers.google.com/actions/assistant/responses#suggestion_chips

...