2023-06-12 00:33:45 -04:00
|
|
|
@import "chat-unread-indicator";
|
2023-05-15 09:53:18 -04:00
|
|
|
@import "chat-height-mixin";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "base-common";
|
2024-07-16 06:34:37 -04:00
|
|
|
@import "chat-drawer-routes";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-browse";
|
2023-04-25 04:23:03 -04:00
|
|
|
@import "chat-channel";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-channel-card";
|
2024-01-25 09:30:21 -05:00
|
|
|
@import "chat-channel-icon";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-channel-info";
|
2024-01-25 09:30:21 -05:00
|
|
|
@import "chat-channel-name";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-channel-preview-card";
|
|
|
|
@import "chat-channel-title";
|
|
|
|
@import "chat-composer-dropdown";
|
|
|
|
@import "chat-composer-upload";
|
|
|
|
@import "chat-composer-uploads";
|
2024-11-29 16:39:18 -05:00
|
|
|
@import "chat-thread-heading";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-composer";
|
2023-05-16 11:17:12 -04:00
|
|
|
@import "chat-composer-button";
|
DEV: adds blocks support to chat messages (#29782)
Blocks allow BOTS to augment the capacities of a chat message. At the moment only one block is available: `actions`, accepting only one type of element: `button`.
<img width="708" alt="Screenshot 2024-11-15 at 19 14 02" src="https://github.com/user-attachments/assets/63f32a29-05b1-4f32-9edd-8d8e1007d705">
# Usage
```ruby
Chat::CreateMessage.call(
params: {
message: "Welcome!",
chat_channel_id: 2,
blocks: [
{
type: "actions",
elements: [
{ value: "foo", type: "button", text: { text: "How can I install themes?", type: "plain_text" } }
]
}
]
},
guardian: Discourse.system_user.guardian
)
```
# Documentation
## Blocks
### Actions
Holds interactive elements: button.
#### Fields
| Field | Type | Description | Required? |
|--------|--------|--------|--------|
| type | string | For an actions block, type is always `actions` | Yes |
| elements | array | An array of interactive elements, maximum 10 elements | Yes |
| block_id | string | An unique identifier for the block, will be generated if not specified. It has to be unique per message | No |
#### Example
```json
{
"type": "actions",
"block_id": "actions_1",
"elements": [...]
}
```
## Elements
### Button
#### Fields
| Field | Type | Description | Required? |
|--------|--------|--------|--------|
| type | string | For a button, type is always `button` | Yes |
| text | object | A text object holding the type and text. Max 75 characters | Yes |
| value | string | The value returned after the interaction has been validated. Maximum length is 2000 characters | No |
| style | string | Can be `primary` , `success` or `danger` | No |
| action_id | string | An unique identifier for the action, will be generated if not specified. It has to be unique per message | No |
#### Example
```json
{
"type": "actions",
"block_id": "actions_1",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Ok"
},
"value": "ok",
"action_id": "button_1"
}
]
}
```
## Interactions
When a user interactions with a button the following flow will happen:
- We send an interaction request to the server
- Server checks if the user can make this interaction
- If the user can make this interaction, the server will:
* `DiscourseEvent.trigger(:chat_message_interaction, interaction)`
* return a JSON document
```json
{
"interaction": {
"user": {
"id": 1,
"username": "j.jaffeux"
},
"channel": {
"id": 1,
"title": "Staff"
},
"message": {
"id": 1,
"text": "test",
"user_id": -1
},
"action": {
"text": {
"text": "How to install themes?",
"type": "plain_text"
},
"type": "button",
"value": "click_me_123",
"action_id": "bf4f30b9-de99-4959-b3f5-632a6a1add04"
}
}
}
```
* Fire a `appEvents.trigger("chat:message_interaction", interaction)`
2024-11-19 01:07:58 -05:00
|
|
|
@import "chat-message-blocks";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-drawer";
|
|
|
|
@import "chat-emoji-picker";
|
|
|
|
@import "chat-form";
|
|
|
|
@import "chat-index";
|
|
|
|
@import "chat-mention-warnings";
|
|
|
|
@import "chat-message-actions";
|
|
|
|
@import "chat-message-collapser";
|
|
|
|
@import "chat-message-images";
|
|
|
|
@import "chat-message-info";
|
|
|
|
@import "chat-message-left-gutter";
|
|
|
|
@import "chat-message-separator";
|
2023-04-11 21:09:06 -04:00
|
|
|
@import "chat-message-thread-indicator";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-message";
|
2023-07-06 09:26:25 -04:00
|
|
|
@import "chat-notices";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-onebox";
|
|
|
|
@import "chat-reply";
|
|
|
|
@import "chat-replying-indicator";
|
|
|
|
@import "chat-selection-manager";
|
|
|
|
@import "chat-skeleton";
|
|
|
|
@import "chat-thread";
|
2023-04-25 04:23:03 -04:00
|
|
|
@import "chat-side-panel-resizer";
|
|
|
|
@import "chat-upload-drop-zone";
|
2023-03-17 09:24:38 -04:00
|
|
|
@import "chat-transcript";
|
|
|
|
@import "core-extensions";
|
|
|
|
@import "dc-filter-input";
|
|
|
|
@import "incoming-chat-webhooks";
|
|
|
|
@import "reviewable-chat-message";
|
2023-05-10 05:42:32 -04:00
|
|
|
@import "chat-thread-list-item";
|
2023-05-15 08:39:11 -04:00
|
|
|
@import "chat-threads-list";
|
2023-05-22 11:00:50 -04:00
|
|
|
@import "chat-composer-separator";
|
2023-05-29 03:11:55 -04:00
|
|
|
@import "chat-thread-header";
|
2023-06-07 15:49:15 -04:00
|
|
|
@import "chat-thread-list-header";
|
2023-05-29 03:11:55 -04:00
|
|
|
@import "chat-thread-unread-indicator";
|
2023-06-14 20:49:27 -04:00
|
|
|
@import "chat-thread-participants";
|
2023-06-19 03:50:54 -04:00
|
|
|
@import "chat-message-error";
|
2023-07-05 12:18:27 -04:00
|
|
|
@import "chat-message-creator";
|
2023-07-10 03:36:20 -04:00
|
|
|
@import "chat-user-avatar";
|
2023-07-10 07:43:33 -04:00
|
|
|
@import "chat-modal-new-message";
|
|
|
|
@import "chat-modal-archive-channel";
|
|
|
|
@import "chat-modal-edit-channel-description";
|
|
|
|
@import "chat-modal-create-channel";
|
|
|
|
@import "chat-modal-create-channel";
|
|
|
|
@import "chat-modal-channel-summary";
|
|
|
|
@import "chat-modal-move-message-to-channel";
|
2023-07-27 03:57:03 -04:00
|
|
|
@import "chat-scroll-to-bottom";
|
2023-09-11 08:51:13 -04:00
|
|
|
@import "chat-channel-row";
|
2023-10-09 08:11:16 -04:00
|
|
|
@import "chat-channel-members";
|
|
|
|
@import "chat-channel-settings";
|
2023-12-11 01:38:07 -05:00
|
|
|
@import "chat-user-threads";
|
|
|
|
@import "chat-navbar";
|
|
|
|
@import "chat-thread-title";
|
2023-12-22 03:38:21 -05:00
|
|
|
@import "chat-audio-upload";
|
2024-02-20 03:49:19 -05:00
|
|
|
@import "chat-message-text";
|
2024-04-25 04:47:54 -04:00
|
|
|
@import "chat-messages-scroller";
|
2024-05-28 09:00:04 -04:00
|
|
|
@import "chat-footer";
|