# Chat Room and Messages - TapUI

The following methods from the **TapUI** class can be used to open a chat room when UI implementation type is used.

| TapTalk UI Chat Room Method                                                                                                                                                                | Description                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [Open Chat Room With User Model](#open-chat-room-with-user-model)                                                                                                                          | Opens a chat room using the recipient user model. This method will directly open the chat room activity.                                   |
| [Open Chat Room with TapTalk.io User ID](#open-chat-room-with-taptalk.io-user-id)                                                                                                          | Opens a chat room using TapTalk.io user ID of the recipient user. This method will directly open the chat room activity.                   |
| [Open Chat Room with Client User ID](#open-chat-room-with-client-user-id)                                                                                                                  | Opens a chat room using client user ID of the recipient user. This method will directly open the chat room activity.                       |
| [Open Room with Room Model](/powertalk-chat-sdk-documentation/powertalk-android/group-chat/tapui.md#open-room-with-room-model)                                                             | Opens a chat room using an available room model. This method will directly open the chat room activity.                                    |
| [Open Room with Room Model & Scroll to Selected Message](/powertalk-chat-sdk-documentation/powertalk-android/group-chat/tapui.md#open-room-with-room-model-and-scroll-to-selected-message) | Opens a chat room using an available room model. This method will directly open the chat room and scroll the view to the selected message. |
| [Open Saved Messages Chat Room](#open-saved-messages-chat-room)                                                                                                                            | Opens of the active user's Saved Messages chat room. This method will directly open the chat room activity.                                |

### Open Chat Room With User Model

Opens a chat room using the recipient user model. This method will directly open the chat room activity.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Model.TAPUserModel;

...

TapUI.getInstance().openChatRoomWithOtherUser(CONTEXT, RECIPIENT_USER);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI
import io.taptalk.TapTalk.Model.TAPUserModel

...

TapUI.getInstance().openChatRoomWithOtherUser(CONTEXT, RECIPIENT_USER)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`RECIPIENT_USER`**: (TAPUserModel) the recipient user to chat with
{% endhint %}

### Open Chat Room with TapTalk.io User ID

Opens a chat room using client user ID of the recipient user. This method will directly open the chat room activity.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Listener.TapCommonListener;

...

TapUI.getInstance().openChatRoomWithUserID(
    CONTEXT,
    USER_ID,
    PREFILLED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO,
    new TapCommonListener() {
        @Override
        public void onSuccess(String successMessage) {
            // Chat room opened successfully
        }
    
        @Override
        public void onError(String errorCode, String errorMessage) {
    
        }
    }
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI
import io.taptalk.TapTalk.Listener.TapCommonListener

...

TapUI.getInstance().openChatRoomWithUserID(
    CONTEXT,
    USER_ID,
    PREFILLED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO,
    object : TapCommonListener() {
        override fun onSuccess(successMessage: String?) {
            // Chat room opened successfully
        }
    
        override fun onError(errorCode: String?, errorMessage: String?) {
    
        }
    }
)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`USER_ID`**: (String) Taptalk.io User ID of the recipient user\
\&#xNAN;**`PREFILLED_TEXT`**: (String) if not empty, the active user's chat composer will be filled with this predefined message when the chat room is opened (existing draft will be replaced)\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL`**: (String) image URL string of custom quote\
\&#xNAN;**`USER_INFO`**: (HashMap\<String , Object>) client-specified data or details of the custom quote
{% endhint %}

### Open Chat Room with Client User ID

Opens a chat room using client user ID (XCUserID) of the recipient user. This method will directly open the chat room activity.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Listener.TapCommonListener;

...

TapUI.getInstance().openChatRoomWithXCUserID(
    CONTEXT,
    XC_USER_ID,
    PREFFILED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO,
    new TapCommonListener() {
        @Override
        public void onSuccess(String successMessage) {
            // Chat room opened successfully
        }
    
        @Override
        public void onOpenRoomFailed(String errorMessage) {
    
        }
    }
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI
import io.taptalk.TapTalk.Listener.TapCommonListener

...

TapUI.getInstance().openChatRoomWithXCUserID(
    CONTEXT,
    XC_USER_ID,
    PREFFILED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO,
    object : TapCommonListener() {
        override fun onSuccess(successMessage: String?) {
            // Chat room opened successfully
        }
    
        fun onOpenRoomFailed(errorMessage: String) {
    
        }
    }
)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`XC_USER_ID`**: (String) Client User ID of the recipient user\
\&#xNAN;**`PREFILLED_TEXT`**: (String) if not empty, the active user's chat composer will be filled with this predefined message when the chat room is opened (existing draft will be replaced)\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL`**: (String) image URL string of custom quote\
\&#xNAN;**`USER_INFO`**: (HashMap\<String , Object>) client-specified data or details of the custom quote
{% endhint %}

### Open Room with Room Model

Opens a chat room using an available room model. This method will directly open the chat room activity.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Model.TAPRoomModel;

...

TapUI.getInstance().openChatRoomWithRoomModel(CONTEXT, ROOM);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI
import io.taptalk.TapTalk.Model.TAPRoomModel

...

TapUI.getInstance().openChatRoomWithRoomModel(CONTEXT, ROOM)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`ROOM`**: (TAPRoomModel) existing chat room data to open
{% endhint %}

The `openChatRoomWithRoomModel()` method with extra parameters below is used when you wish to set a predefined quote for the user in the opened chat room.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Model.TAPRoomModel;

...

TapUI.getInstance().openChatRoomWithRoomModel(
    CONTEXT,
    ROOM,
    PREFILLED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Model.TAPRoomModel;

...

TapUI.getInstance().openChatRoomWithRoomModel(
    CONTEXT,
    ROOM,
    PREFILLED_TEXT,
    CUSTOM_QUOTE_TITLE,
    CUSTOM_QUOTE_CONTENT,
    CUSTOM_QUOTE_IMAGE_URL,
    USER_INFO
)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`ROOM`**: (TAPRoomModel) existing chat room data to open\
\&#xNAN;**`PREFILLED_TEXT`**: (String) if not empty, the active user's chat composer will be filled with this predefined message when the chat room is opened (existing draft will be replaced)\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL_STRING`**: (String) image URL string of custom quote\
\&#xNAN;**`USER_INFO`**: (HashMap\<String , Object>) client-specified data or details of the custom quote
{% endhint %}

### Open Room with Room Model & Scroll to Selected Message

Opens a chat room using an available room model. This method will directly open the chat room and scroll the view to the selected message.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;
import io.taptalk.TapTalk.Model.TAPRoomModel;

...

TapUI.getInstance().openChatRoomWithRoomModel(
    CONTEXT,
    ROOM,
    SCROLL_TO_MESSAGE_WITH_LOCAL_ID
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI
import io.taptalk.TapTalk.Model.TAPRoomModel

...

TapUI.getInstance().openChatRoomWithRoomModel(
    CONTEXT,
    ROOM,
    SCROLL_TO_MESSAGE_WITH_LOCAL_ID
)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context\
\&#xNAN;**`ROOM`**: (TAPRoomModel) existing chat room data to open\
\&#xNAN;**`SCROLL_TO_MESSAGE_WITH_LOCAL_ID`**: (String) scrolls the view to the message with the specified local ID when the chat room is opened
{% endhint %}

### Open Saved Messages Chat Room

Opens of the active user's Saved Messages chat room. This method will directly open the chat room activity.

{% tabs %}
{% tab title="Java" %}

```java
import io.taptalk.TapTalk.Manager.TapUI;

...

TapUI.getInstance().openSavedMessagesChatRoom(CONTEXT);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.taptalk.TapTalk.Manager.TapUI

...

TapUI.getInstance().openSavedMessagesChatRoom(CONTEXT)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`CONTEXT`**: (Context) your Application or Activity context
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-android/group-chat/tapui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
