# SmartReplyGenerator

public interface **SmartReplyGenerator** extends [Closeable](https://developer.android.com/reference/java/io/Closeable.html) LifecycleObserver [OptionalModuleApi](https://developers.google.com/android/reference/com/google/android/gms/common/api/OptionalModuleApi.html) A `https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReply`
client for suggesting meaningful replies to a user input message.

A `https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator`
is created via `https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReply#getClient()`.

Example:

    SmartReplyGenerator smartReplyGenerator = SmartReply.getClient();
     
### Public Method Summary

|---|---|
| abstract void | [close](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator#close())() Closes the underlying resources including models used for reply inference. |
| abstract Task\<[SmartReplySuggestionResult](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult)\> | [suggestReplies](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplyGenerator#suggestReplies(java.util.List<com.google.mlkit.nl.smartreply.TextMessage>))([List](https://developer.android.com/reference/java/util/List.html)\<[TextMessage](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\> textMessages) Returns suggested meaningful replies to a text message. |

### Inherited Method Summary

From interface java.io.Closeable

|---|---|
| abstract void | close() |

From interface java.lang.AutoCloseable

|---|---|
| abstract void | close() |

## Public Methods

#### public abstract void **close** ()

Closes the underlying resources including models used for reply inference.

#### public abstract Task\<[SmartReplySuggestionResult](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult)\>
**suggestReplies** ([List](https://developer.android.com/reference/java/util/List.html)\<[TextMessage](https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/TextMessage)\> textMessages)

Returns suggested meaningful replies to a text message.

Currently, English is the only supported language.

##### Parameters

| textMessages | a list of messages from which the API generates smart replies. The messages list should contain most recent conversation context for all users participating in the conversation in ascending chronological order (i.e. from oldest to newest). Internally, SmartReply considers the last 10 messages to generate reply suggestions. |
|---|---|

##### Returns

- a `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task` that asynchronously returns a `https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestionResult` which contains a list of `https://developers.google.com/android/reference/com/google/mlkit/nl/smartreply/SmartReplySuggestion`s. All the replies are sorted by an internal confidence value (highest to lowest).