Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

actions on google - How to close conversation from the webhook in @assistant/conversation

I want to close the conversation after the media started playing in @assistant/conversation. As I am doing here

app.intent("media", conv => {
    conv.ask(`Playing your Radio`);
    conv.ask(
        new MediaObject({
            url: ""
        })
    );
    return conv.close(new Suggestions(`exit`));
});
question from:https://stackoverflow.com/questions/65853185/how-to-close-conversation-from-the-webhook-in-assistant-conversation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As Jordi had mentioned, suggestion chips cannot be used to close a conversation. Additionally, the syntax of the @assistant/conversation is different from actions-on-google. As you're using the tag dialogflow-es-fulfillment but also actions-builder, I really don't know which answer you want. As such, I'm going to put two answers depending on which you're using.

Dialogflow

If you are using Dialogflow, you are pretty much set. You should switch to using actions-on-google and instantiate the dialogflow constant.

const {dialogflow} = require('actions-on-google')
const app = dialogflow()

Actions Builder

The syntax of the @assistant/conversation lib is different. Some method names are different. Additionally, you will need to go through Actions Builder to canonically close the conversation.

In your scene, you will need to transition the scene to End Conversation to close, rather than specifying it as part of your response. Still, your end transition should not have suggestion chips.

enter image description here

You will need to refactor your webhook:

const {conversation} = require('@assistant/conversation')
const app = conversation()

app.handle("media", conv => {
    conv.add(`Playing your Radio`);
    conv.add(
        new MediaObject({
            url: ""
        })
    );
    conv.add(new Suggestions(`exit`));
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...