2023-06-12 12:33:45 +08:00
|
|
|
@import "chat-unread-indicator";
|
2023-05-15 21:53:18 +08:00
|
|
|
@import "chat-height-mixin";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "base-common";
|
2024-07-16 18:34:37 +08:00
|
|
|
@import "chat-drawer-routes";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-browse";
|
2023-04-25 16:23:03 +08:00
|
|
|
@import "chat-channel";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-channel-card";
|
2024-01-25 22:30:21 +08:00
|
|
|
@import "chat-channel-icon";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-channel-info";
|
2024-01-25 22:30:21 +08:00
|
|
|
@import "chat-channel-name";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-channel-preview-card";
|
|
|
|
@import "chat-channel-title";
|
|
|
|
@import "chat-composer-dropdown";
|
|
|
|
@import "chat-composer-upload";
|
|
|
|
@import "chat-composer-uploads";
|
2024-11-30 05:39:18 +08:00
|
|
|
@import "chat-thread-heading";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-composer";
|
2023-05-16 23:17:12 +08: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 14:07:58 +08:00
|
|
|
@import "chat-message-blocks";
|
2023-03-17 21:24:38 +08: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-12 09:09:06 +08:00
|
|
|
@import "chat-message-thread-indicator";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-message";
|
2023-07-06 21:26:25 +08:00
|
|
|
@import "chat-notices";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-onebox";
|
|
|
|
@import "chat-reply";
|
|
|
|
@import "chat-replying-indicator";
|
|
|
|
@import "chat-selection-manager";
|
|
|
|
@import "chat-skeleton";
|
|
|
|
@import "chat-thread";
|
2023-04-25 16:23:03 +08:00
|
|
|
@import "chat-side-panel-resizer";
|
|
|
|
@import "chat-upload-drop-zone";
|
2023-03-17 21:24:38 +08:00
|
|
|
@import "chat-transcript";
|
|
|
|
@import "core-extensions";
|
|
|
|
@import "dc-filter-input";
|
|
|
|
@import "incoming-chat-webhooks";
|
|
|
|
@import "reviewable-chat-message";
|
2023-05-10 17:42:32 +08:00
|
|
|
@import "chat-thread-list-item";
|
2023-05-15 20:39:11 +08:00
|
|
|
@import "chat-threads-list";
|
2023-05-22 23:00:50 +08:00
|
|
|
@import "chat-composer-separator";
|
2023-05-29 15:11:55 +08:00
|
|
|
@import "chat-thread-header";
|
2023-06-08 03:49:15 +08:00
|
|
|
@import "chat-thread-list-header";
|
2023-05-29 15:11:55 +08:00
|
|
|
@import "chat-thread-unread-indicator";
|
2023-06-15 08:49:27 +08:00
|
|
|
@import "chat-thread-participants";
|
2023-06-19 15:50:54 +08:00
|
|
|
@import "chat-message-error";
|
2023-07-06 00:18:27 +08:00
|
|
|
@import "chat-message-creator";
|
2023-07-10 15:36:20 +08:00
|
|
|
@import "chat-user-avatar";
|
2023-07-10 19:43:33 +08: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 15:57:03 +08:00
|
|
|
@import "chat-scroll-to-bottom";
|
2023-09-11 20:51:13 +08:00
|
|
|
@import "chat-channel-row";
|
2023-10-09 20:11:16 +08:00
|
|
|
@import "chat-channel-members";
|
|
|
|
@import "chat-channel-settings";
|
2023-12-11 14:38:07 +08:00
|
|
|
@import "chat-user-threads";
|
|
|
|
@import "chat-navbar";
|
|
|
|
@import "chat-thread-title";
|
2023-12-22 16:38:21 +08:00
|
|
|
@import "chat-audio-upload";
|
2024-02-20 16:49:19 +08:00
|
|
|
@import "chat-message-text";
|
2024-04-25 16:47:54 +08:00
|
|
|
@import "chat-messages-scroller";
|
2024-05-28 21:00:04 +08:00
|
|
|
@import "chat-footer";
|