API Overview
createDialogflow
Creates a dialog manager that maintains the dialog state.
ts
import { createDialogflow } from 'dialogflow-react';
const dialogflow = createDialogflow();
DialogProvider
A provider component that supplies dialog management functionalities via context.
tsx
<DialogProvider manager={dialogflow}>
{children}
</DialogProvider>
- Props:
manager
: The dialog manager instance created bycreateDialogflow
.
useDialog
A hook that provides push
, open
, and close
functions to manage dialogs.
ts
const { push, open, close } = useDialog();
push(Component, props?)
Pushes a new dialog component onto the stack.
Component
: The dialog component to render.props
(optional): Props to pass to the dialog component.
Returns a promise that resolves to the result passed to
close
.open(dialogId, props?)
Opens a registered dialog component.
dialogId
: The ID of the registered dialog component.props
(optional): Props to pass to the dialog component.
Returns a promise that resolves to the result passed to
close
. Throws an error if the dialog is not registered or is already open.