TextMessage
Stay organized with collections
Save and categorize content based on your preferences.
Represents a text message from a certain user in a conversation, providing context for
SmartReply to generate reply suggestions.
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Methods
public static TextMessage
createForLocalUser (String messageText,
long timestampMillis)
Creates an instance of TextMessage
for a local user. The local user is the current user of the app's instance and is the
user for which SmartReply is generating a reply.
Parameters
messageText |
the message content. |
timestampMillis |
timestamp of the message in milliseconds since midnight, January 1, 1970 UTC.
You can use, for example, java.lang.System.currentTimeMillis() to
get the value.
|
public static TextMessage
createForRemoteUser (String messageText,
long timestampMillis, String
remoteUserId)
Creates an instance of TextMessage
for a remote user. Your local user may have a conversation with one or more remote
users and providing context for messages your local user has received will help the API
generate smart replies.
Parameters
messageText |
the message content. |
timestampMillis |
timestamp of the message in milliseconds since midnight, January 1, 1970 UTC.
You can use, for example, java.lang.System.currentTimeMillis() to
get the value.
|
remoteUserId |
a unique user ID representing a remote user if the local user is having a
conversation with more than one remote user. It's only used to distinguish
participants in the conversation.
SmartReplyGenerator
is a stateless API, so there is no need to guarantee consistent user IDs across
different API calls.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eTextMessage\u003c/code\u003e represents a text message within a conversation for Smart Reply.\u003c/p\u003e\n"],["\u003cp\u003eIt provides context for the Smart Reply API to generate relevant suggestions.\u003c/p\u003e\n"],["\u003cp\u003eYou can create instances for both local and remote users using static methods.\u003c/p\u003e\n"],["\u003cp\u003eMessages include content, timestamp, and optionally a remote user ID for context.\u003c/p\u003e\n"]]],["TextMessage represents a text message within a conversation, aiding SmartReply in generating suggestions. Key actions involve creating TextMessage instances: `createForLocalUser` for the app's current user, requiring the message content and timestamp in milliseconds. `createForRemoteUser` is for other users in the conversation, necessitating the message content, timestamp, and a unique remote user ID. These methods provide contextual information to SmartReply for suggesting appropriate replies.\n"],null,["# TextMessage\n\npublic final class **TextMessage** extends [Object](https://developer.android.com/reference/java/lang/Object.html) \nRepresents a text message from a certain user in a conversation, providing context for\nSmartReply to generate reply suggestions. \n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage) | [createForLocalUser](/android/reference/com/google/mlkit/nl/smartreply/TextMessage#createForLocalUser(java.lang.String,%20long))([String](https://developer.android.com/reference/java/lang/String.html) messageText, long timestampMillis) Creates an instance of [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage) for a local user. |\n| static [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage) | [createForRemoteUser](/android/reference/com/google/mlkit/nl/smartreply/TextMessage#createForRemoteUser(java.lang.String,%20long,%20java.lang.String))([String](https://developer.android.com/reference/java/lang/String.html) messageText, long timestampMillis, [String](https://developer.android.com/reference/java/lang/String.html) remoteUserId) Creates an instance of [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage) for a remote user. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](https://developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\n**createForLocalUser** ([String](https://developer.android.com/reference/java/lang/String.html) messageText, long timestampMillis)\n\nCreates an instance of [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\nfor a local user. The local user is the current user of the app's instance and is the\nuser for which SmartReply is generating a reply. \n\n##### Parameters\n\n| messageText | the message content. |\n| timestampMillis | timestamp of the message in milliseconds since midnight, January 1, 1970 UTC. You can use, for example, `java.lang.System.currentTimeMillis()` to get the value. |\n|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public static [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\n**createForRemoteUser** ([String](https://developer.android.com/reference/java/lang/String.html) messageText, long timestampMillis, [String](https://developer.android.com/reference/java/lang/String.html) remoteUserId)\n\nCreates an instance of [TextMessage](/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\nfor a remote user. Your local user may have a conversation with one or more remote\nusers and providing context for messages your local user has received will help the API\ngenerate smart replies. \n\n##### Parameters\n\n| messageText | the message content. |\n| timestampMillis | timestamp of the message in milliseconds since midnight, January 1, 1970 UTC. You can use, for example, `java.lang.System.currentTimeMillis()` to get the value. |\n| remoteUserId | a unique user ID representing a remote user if the local user is having a conversation with more than one remote user. It's only used to distinguish participants in the conversation. [SmartReplyGenerator](/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator) is a stateless API, so there is no need to guarantee consistent user IDs across different API calls. |\n|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]