actions-on-googleactions-builder

How to close a conversation in the @assistant/conversation


I have created a cloud function to handle some logics in which i would like to close the conversation.

I have tried the following but i have got an error stating that there is no method named close in the conversation

conv.close('Thankyou');

I have checked the documentation of @assistant/conversation where there is no method to close a conversation

enter image description here

I would like to know how to close a conversation from the cloud function as well as is it possible to use the system scenes in the cloud function for example

To end a conversation in a scene we would transit to the End conversation scene. Similarly in the cloud function can we use it

conv.scene.next.name = 'End conversation'

For the custom scene which we create, it works fine but if we try to use the system scenes in the cloud function it fails.


Solution

  • The simplest way to transition to exit directly is to use the special "End Conversation" scene name: actions.page.END_CONVERSATION.

    Another reasonable approach, however, would be to transition to a Scene, and the primary thing that Scene does is transition to ending the conversation. Since you can't transition as part of the Entry message, you'll need to create a condition that is "true".

    Illustration of Exit scene

    This may seem like an unnecessary hack, but this isn't as crazy as it sounds - for some Actions, it would make sense to have a common closing and cleanup process, and centralizing them in one logical place makes sense.