Invertase
Invertase

Notice: This documentation is currently a work in progress for the upcoming v6 release and some content may be missing or incomplete. If you're not interested in testing out the alpha version of v6 then please click here to be taken to the v5 documentation.

message  Send Feedback

SmartReplyConversation

A class representing a Smart Reply conversation in your app.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();

Methods

addLocalUserMessage

addLocalUserMessage(text: string, timestamp?: undefined | number): void;

Add a local message to this conversation, e.g. for the currently signed in user on this device.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();
conversation.addRemoteUserMessage('Hey, want to get lunch today?', Date.now(), 'jimBobTheGreat');
conversation.addLocalUserMessage('That sounds great!');
conversation.addRemoteUserMessage('Great, does 12pm work for you?', Date.now(), 'jimBobTheGreat');
const suggestedReplies = await conversation.getSuggestedReplies();
console.log(suggestedReplies); // [ { text: 'Sure' }, ...etc ]
Parameters
  • text
    The local users message text.
  • timestamp
    The timestamp of when the message was created.

addRemoteUserMessage

addRemoteUserMessage(text: string, timestamp: number, remoteUserId: string): void;

Add a remote message to this conversation, e.g. for a user that's not on this device.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();
conversation.addRemoteUserMessage('hey, want to get lunch today?', Date.now(), 'jimBobTheGreat');
const suggestedReplies = await conversation.getSuggestedReplies();
console.log(suggestedReplies); // [ { text: 'Sure' }, ...etc ]
Parameters
  • text
    The remote users message text.
  • timestamp
    The timestamp of when the message was received.
  • remoteUserId
    The remote users identifier in your app.

clearMessages

clearMessages(): void;

Removes all messages from this conversation, e.g. all messages added via addLocalUserMessage and addRemoteUserMessage.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();
conversation.addRemoteUserMessage('hey, want to get lunch today?', Date.now(), 'jimBobTheGreat');
// start over
conversation.clearMessages();

getSuggestedReplies

getSuggestedReplies(): Promise<>;

Get suggested replies for the current conversation.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();
conversation.addRemoteUserMessage('hey, want to get lunch today?', Date.now(), 'jimBobTheGreat');
const suggestedReplies = await conversation.getSuggestedReplies();
console.log(suggestedReplies); // [ { text: 'Sure' }, ...etc ]