Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to end the conversation with API.AI

Is there a way to end Google Home's conversation with the server using API.AI?

I am assuming that somehow I need to access expect_user_response and set it to false.

I also see with the actions SDK you can use 'assistant.tell()', but that does not seem accessible with API.AI.

like image 856
SysCoder Avatar asked Jan 04 '23 21:01

SysCoder


2 Answers

For people that are not using the SDK. There are two ways that I found to stop the mic on Google Home while using API.AI.

In the "Intent" pane, under fulfillment, there is an "Actions on Google" section that you can expand. Under that you will see "End Conversation" check box. Check that box.

In your fulfillment include the following:

data: {
  google: {
    expect_user_response: false,
  }
}

Add this at the same level as your speech property in your response.

like image 165
SysCoder Avatar answered Feb 04 '23 16:02

SysCoder


Yes, you can. In your app, write a function that sends the query "stop" to your agent.

function stop_conversation(){ var api_request = new Request('https://api.api.ai/v1/query?v=20150910', {
        method: 'POST',
        mode: 'cors',
        redirect: 'follow',
        headers: {
            'Authorization': 'Bearer 21f6a5778d484870ad46be4d34ac2eeb',
            'content-Type': 'application/json; charset=utf-8'
        },
        body: JSON.stringify({
            q: 'stop',
            lang: 'en',
            sessionId: '44628d21-d7a4-47d5-b1c6-a7f851be65fv'
        })
    });
}

If you're using the fulfillment library then invoke Assist('stop');.

...

In the "Intent" pane, under fulfillment, there is an "Actions on Google" section that you can expand. Under that, you will see "End Conversation" check that box.

In your fulfillment include the following:

data: {
  google: {
    expect_user_response: false,
  }
}

Add this at the same level as your speech property in your response.

like image 31
assist ant Avatar answered Feb 04 '23 16:02

assist ant