Class: Conversation

Properties

defaultCountry

Static Readonly defaultCountry: "us" = "us"


defaultModel

Static Readonly defaultModel: "en" = "en"


validCountries

Static Readonly validCountries: Set<string> = new Set(["fr", "us"])


validModels

Static Readonly validModels: Set<string> = new Set(["es", "fr", "en"])

Events Methods

onClose

onClose(callback: () => void): Conversation

Subscribe to Conversation onClose event.

example

const uhlive = new Uhlive("my-token");
const conversation = uhlive.join("test");
conversation.onClose(() => {
// Choose what to do when the conversation is closed.
})

Parameters:

NameType
callback() => void

Returns: Conversation


onEntityFound

onEntityFound(entityName: EntityEvent | "*", callback: (entity: Entity,entityName: EntityEvent) => void): Conversation

This event is triggered when the specified entity has been found or the wildcard is used and any entity is found.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onEntityFound("LocationCity", (entity) => {
// Do something with `entity`...
});

Parameters:

NameType
entityNameEntityEvent | "*"
callback(entity: Entity,entityName: EntityEvent) => void

Returns: Conversation


onEntityRelationFound

onEntityRelationFound(relationName: EntitiesRelationEvent | "*", callback: (entities: EntityRef[]) => void): Conversation

This event is triggered when an entity with possible relations is found.
It is emitted event if only one entity is found.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onEntityRelationFound("CreditCard", (relation) => {
// Do something with `relation`...
});

Parameters:

NameType
relationNameEntitiesRelationEvent | "*"
callback(entities: EntityRef[]) => void

Returns: Conversation


onError

onError(callback: (payload: any) => void): Conversation

Subscribe to Conversation onError event.

example

const uhlive = new Uhlive("my-token");
const conversation = uhlive.join("test");
conversation.onError((msg) => console.log(msg))

Parameters:

NameType
callback(payload: any) => void

Returns: Conversation


onSegmentDecoded

onSegmentDecoded(callback: (transcript: SegmentDecoded) => void): Conversation

The onSegmentDecoded event is triggered when a final transcript is received.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onSegmentDecoded((transcript) => {
// Do something with `transcript`...
});

Parameters:

NameType
callback(transcript: SegmentDecoded) => void

Returns: Conversation


onSpeakerJoined

onSpeakerJoined(callback: (payload: SpeakerJoined) => void): Conversation

The speaker_joined event is triggered when a speaker join the conversation. It is sent to everyone except the speaker itself. Note that users connected in read-only mode (observers) don't emit this event.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onSpeakerJoined((payload) => {
// Do something with `payload`...
});

Parameters:

NameType
callback(payload: SpeakerJoined) => void

Returns: Conversation


onSpeakerLeft

onSpeakerLeft(callback: (payload: SpeakerLeft) => void): Conversation

The speaker_left event is triggered when a speaker leaves, or more abruptly, closes its connection. This event is published after all remaining transcript events of this speaker have been published. Note that users connected in read-only mode (observers) don't emit this event.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onSpeakerLeft((speaker) => {
// Do something with `speaker`...
});

Parameters:

NameType
callback(payload: SpeakerLeft) => void

Returns: Conversation


onWordsDecoded

onWordsDecoded(callback: (transcript: WordsDecoded) => void): Conversation

The words_decoded event is triggered when an interim transcript is received. Following words_decoded events for the same audio are susceptible to be different, until a final transcript is sent with the segment_decoded event.

example

const uhlive = new Uhlive("my-token");
const myConversation = uhlive.join("my-conversation");
myConversation.onWordsDecoded((transcript) => {
// Do something with `transcript`...
});

Parameters:

NameType
callback(transcript: WordsDecoded) => void

Returns: Conversation


Recording Methods

isRecording

isRecording(): boolean

Get the recording status of the conversation.

example

const uhlive = new Uhlive("my-token");
uhlive
.join("my-conversation")
.isRecording(); // true

example

const uhlive = new Uhlive("my-token");
uhlive
.join("my-conversation", {readonly: true})
.isRecording(); // false

Returns: boolean