Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 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 Answer

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`));
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...