Events manager
How events are emitted and consumed.
What is the Events Manager
The Events Manager consumes realtime events during conversations - it provides a framework to consume and take action on these events asychronously.
Current Event Types
The current event types include:
TRANSCRIPT
: Indicates a partial transcript for the conversation has been received.TRANSCRIPT_COMPLETE
: Indicates the transcript is complete (ie conversation has ended).ACTION
: Indicates that a Vocode action has begun or completed.PHONE_CALL_CONNECTED
: Indicates a phone call has been connected (only gets sent duringPhoneConversation
s)PHONE_CALL_ENDED
: Indicates a phone call has ended.
Usage
Using the events manager to take particular action when events fire requires that you subclass vocode.streaming.utils.EventsManager
and override the handle_event
method.
You can also configure which events your EventsManager
is subscribed to by using the subscriptions
property (see example).
Example
In this example, we create a custom EventsManager
subclass is created with a subscription to the TRANSCRIPT_COMPLETE
event and then print the transcript when we receive the event.
To use CustomEventsManager
, you can pass it into any Conversation, e.g.
You can also pass it into a TelephonyServer
, like: