In this article we'll introduce the concept of transaction webhooks in Conversational AI Cloud and what it means for a developer to work with them.
If you want to know more about the request and response for the validation webhook go to the API reference section here
Transaction webhooks are used to validate the end slot in a transactional dialog. An end slot in a transactional dialog is called only when all slots in the transactional dialog have been filled in. Its the final check to determine whether all slots are filled in correctly, and can also be used to post data to an external system like a CRM/OMS or to fetch data based on the acquired data.
A transaction webhook can serve a variety of use cases but as it is a webhook use cases are endless. Transaction webhooks can be used to:
- Validate the sum of provided user input across all slots against an external system like a CRM or OMS.
- Validate the sum of provided user input across all slots against custom logic defined within the webhook.
- Reset a slot of the transactional dialog if validation doesn't pass
- Update the state of the conversation by mutating the session object and returning it in the response of the webhook
When working with the validation webhook its important to keep a few things into account:
- A transaction webhook is called once when all slots in the transactional dialog have a set value. If the transaction webhook decides to reset a slot, it will be called again once that slot is filled again. Ensure you don't get your end-users stuck in a validation loop inside the transactional dialog.
- Only set the "success" value to false if you want the "generic error message" to be returned. The success value should be set to true in all other circumstances. A valid scenario could be an unexpected internal error within the webhook.
- It is not possible to mutate the state of the conversation (session) directly from a validation webhook.
- Transaction webhooks can mutate the state of a session in Conv. AI Cloud. You can however only set a key on the session if that key is defined as a conversation variable in the projects configuration.
- When updating the session object through the webhooks response, it isn't required to specify the entire session object, a partial session object can also be returned. If a partial object is returned it'll be merged with the original session object.
Updated about 1 month ago