# Bottom Input Chat Widget

## Overview

![](https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MWB6l4cGv8_WFPtgW_-%2F-MWB7_L6djf9MUo4y1rg%2FScreen%20Shot%202021-03-19%20at%201.16.47%20PM.png?alt=media\&token=18ecf3c6-7fb4-46f7-aa23-2259bd44c160)

![](https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MWB6l4cGv8_WFPtgW_-%2F-MWB7rM1ZV3L22eW1R4-%2FScreen%20Shot%202021-03-19%20at%201.17.44%20PM.png?alt=media\&token=d6d43c51-f62f-41e9-98bf-7f1da5079d1f)

This block allows a user to manage multiple conversation threads with different users. A user can click into one of the threads and send or view messages/attachments.

## Structure

When this block is added to a page, it is placed within a group called **Blocks container 860 (do not rename)** on the page. This group contains the responsive settings for all blocks.

* **bottominput\_chat**\
  This reusable element contains all of the logic and UI for threads and messages. It contains three main groups:<br>
  * **Group Main threads list\_thread**\
    This group contains the list of threads that the current user is a part of. All of the threads are displayed in **RepeatingGroup t-Thread**. Clicking on **Group Main select thread\_thread** will hide **Group Main threads list\_thread** and show the messages for the selected thread.<br>
  * **Group Main message\_thread**\
    This group displays all messages between users in a thread (in **RepeatingGroup t-Message**). You have two versions of message formats to choose from:

    * **iMessage format**\
      This is the default message format. To hide this style, select **Group Collapsible iMsg\_message** and uncheck the box for This element is visible on page load.\
      \
      &#x20;<img src="https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MGof01lpMD0QeLT27iP%2F-MGwezaetMbUiUvrdrWX%2FScreen%20Shot%202020-09-11%20at%203.14.17%20AM.png?alt=media&#x26;token=c187f2f7-63cd-42bc-bb5f-939083b61c06" alt="" data-size="original"> <br>
    * **Slack format**\
      To use this style, hide **Group Collapsible iMsg\_message** and show **Group Collapsible Slack\_message** by checking the box for This element is visible on page load.\
      &#x20;<img src="https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MGof01lpMD0QeLT27iP%2F-MGwgMYep0FBG_H41CXK%2FScreen%20Shot%202020-09-11%20at%203.20.24%20AM.png?alt=media&#x26;token=20fe8f1e-2527-4b9c-a18f-40d2cc251a81" alt="" data-size="original"> <br>

    Clicking on **Group Inner Back to threads** will navigate back to the list of threads.\
    \
    The user can enter a message in **MultilineInput message** and attach a file by clicking on the file clip icon. When an attachment is added, it will show underneath the message input. Clicking on it will open the attachment in a new tab for previewing. Clicking on **Group Inner delete file** will delete the attachment and allow you upload a new attachment.<br>
  * **Popup Hidden Variables**\
    This popup includes various variables that are referenced in workflows or conditionals on the page.

    * **var - Website object** - This group stores the `website object` (e.g., app name, primary color, and etc.)
    * **var - chat thread** - This group stores the `thread` that the user is currently viewing.&#x20;
    * **var - user viewing chat** - This group stores the `user` information (current user who is viewing the thread and messages).&#x20;
    * **var - attached msg file** - This group temporarily stores a `file` that the current user attaches to a message (this group will be reset when the message is sent).

    For more information on how to use hidden variables, click [here](https://app.gitbook.com/@airdev1/s/canvas/~/drafts/-M3h22ftTUg2MDpeUedQ/using-the-template/setup/features/hidden-variables-popup).

## How to set up

#### Customizing the chat layout by going to the b**ottominput\_chat reusable element**

* In **Popup Hidden Variables**, update **var - user viewing chat's** data source to include any filters for the user who is viewing the chart

  * You would want to keep the data source for this group here to `Current user` and remove the conditional statement (Do a search for users:first item is a placeholder for demo purposes).

  <img src="https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MR1VvGNLaCEXF3EB0-J%2F-MR1mcfi7nuday7XE3Tj%2FScreen%20Shot%202021-01-14%20at%201.25.22%20PM.png?alt=media&#x26;token=4cc19ebf-fe9b-472c-827c-3f32375660a4" alt="" data-size="original">&#x20;

  ![](https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LbzMeM9XfnblRd78nga-47528762%2Fuploads%2FNVUxmc4WOAayoYTI0Y8O%2FScreen%20Shot%202021-10-11%20at%206.26.39%20PM.png?alt=media\&token=f90dc410-9659-4f14-858d-b2c0010c923d)<br>
* Select a message format by showing **Group Collapsible iMsg\_message** or **Group Collapsible Slack\_message**. Hide the format that you are not using.<br>
* \[Optional] Change the iMessage format colors. You can do this by locating the **HTML message styles** in the reusable element and updating the hex color codes. From-me styles will apply to all messages sent by you (current user). From-them styles will apply to all messages sent by the other user(s).

{% hint style="warning" %}
Make sure you save the original code before you change the hex color codes in **HTML message styles**. Sometimes it takes a few page loads to see the html updates on the page. You can preview the updated html styles by doing a hard refresh in the chrome browser (Command + Shift+ R).
{% endhint %}

#### Adding the bottom chat widget reusable to different pages in your app

{% hint style="info" %}
In Bubble, a reusable element is a way to build elements that you can replicate in more than one page without having to recreate them.&#x20;
{% endhint %}

* On the page that you have your chat widget instance, set up a workflow to create a new thread and add the user(s) to the thread.&#x20;
  * For example, you might add a Message user button to the page and include the following workflows:\
    &#x20;&#x20;

![Create a new thread](https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MR1VvGNLaCEXF3EB0-J%2F-MR1qQ8ISQhS0Cwnmcmi%2FScreen%20Shot%202021-01-14%20at%201.41.11%20PM.png?alt=media\&token=5c8b48bb-1a44-426d-ba7d-571a5ff678f1)

![Add the users to the thread. The second user is for demo purposes and should be whoever the user is messaging.](https://1483599141-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbzMeM9XfnblRd78nga%2F-MR1VvGNLaCEXF3EB0-J%2F-MR1qVUjM9mB6ZCfoSq3%2FScreen%20Shot%202021-01-14%20at%201.41.47%20PM.png?alt=media\&token=d1d8518a-d158-4ab7-880a-ae7d56f5dc72)

* The **bottominput\_chat** instance has a data type of type `t-Thread`. To display all of the current user's threads that he or she is a part of, do not set a thread data source. However, if you want to display only one thread for a user (i.e, hiding the threads list view and only showing the thread conversation view, then you should pass a thread to the reusable instance).


---

# 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.airdev.co/canvas-pages-and-modules/modules/bottom-input-chat-widget.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.
