简体   繁体   中英

DialogFlow V2 How set fulfillmentText via node js library?

Following this guide:

https://actions-on-google.github.io/actions-on-google-nodejs/

I created an action for DialogFlow

import { dialogflow, Image, Conversation, BasicCard } from 'actions-on-google';
const app = dialogflow();

app.intent('test', (conv, input) => {
    conv.contexts.set('i_see_context_in_web_demo', 1);
    conv.ask(`i see this only into actions on google simulator`);
    conv.ask(new Image({
url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
alt: 'cat',
    }));
});

I then activated Web Demo integration

I saw that the Web Demo integration does not show the cards, the images. I hypothesize that it only shows text, no rich text

I understand that it elaborates only JSON like this:

{ "fulfillmentText": "Welcome!", "outputContexts": [] }

But I did not find any method in the library used to enhance fulfillmentText

can you help me?

You're using the actions-on-google library , which is specifically designed to send messages that will be used by the Google Assistant. The Web Demo uses the generic messages that are available for Dialogflow. The actions-on-google library does not send these generic messages.

If you want to be able to create messages that are usable by both, you'll need to look into the dialogflow fulfillment library , which can create messages that are usable by the Google Assistant as well as other platforms. Be aware, however, that not all rich messages are available on all platforms, but that the basic text responses should be.

You also don't need to use a library - you can create the JSON response yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM