2

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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
Nidhin Kumar
  • 3,278
  • 9
  • 40
  • 72

1 Answers1

1

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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks,I have used the actions.pages.END_CONVERSATION. I have tried to make it centralize and close the conversation but in that case, if we create a new scene and onEnter prompt if we write our exit message then we can't see a Transition to End the conversation so in that case how do we make our action to exit from the scene.(If we don't have any intents or conditions for that scene) – Nidhin Kumar Aug 29 '20 at 10:18
  • 1
    I restructured the answer, making the end conversation string first, but also providing a better illustration about how to create an Exit scene. – Prisoner Aug 29 '20 at 15:25