|
| 1 | +# MSC0000: Prompts and partial commands for in room commands. |
| 2 | + |
| 3 | +When composing a command, a user may not know what to provide for as an argument to a command. In |
| 4 | +this situation, it is desirable for the client to be able to prompt the user with suggestions for |
| 5 | +the argument. |
| 6 | + |
| 7 | +## Proposal |
| 8 | + |
| 9 | +### The promptable property on parameters |
| 10 | + |
| 11 | +Within the parameter description for a command argument, we specify a new property `promptable` |
| 12 | +which when given the value `true` signals to clients that they may send a _partial commmand_ to the |
| 13 | +bot to receive suggestions for the argument. |
| 14 | + |
| 15 | +### The `m.bot.command_prompt` event |
| 16 | + |
| 17 | +Consider the following command description under the context of MSC4332 and MSC4333. |
| 18 | + |
| 19 | +```jsonc |
| 20 | +{ |
| 21 | + "sigil": "!", |
| 22 | + "commands": [ |
| 23 | + { |
| 24 | + "syntax": "draupnir takedown {entity} {list} {reason}", |
| 25 | + "arguments": { |
| 26 | + "entity": { |
| 27 | + "m.text": [{"body": "The entity to ban"}], |
| 28 | + }, |
| 29 | + "reason": { |
| 30 | + "m.text": [{"body": "The reason for the ban"}], |
| 31 | + }, |
| 32 | + "list": { |
| 33 | + "m.text": [{"body": "The policy list to ban the user on"}], |
| 34 | + "promptable": true, |
| 35 | + }, |
| 36 | + }, |
| 37 | + "description": { |
| 38 | + "m.text": [{"body": "Ban a user in all protected rooms"}], |
| 39 | + }, |
| 40 | + }, |
| 41 | + ] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +When a client is composing the argument for `list`, if the user is unable to make a decision for the |
| 46 | +policy list, the client can send the following `m.bot.command`: |
| 47 | + |
| 48 | +```jsonc |
| 49 | +{ |
| 50 | + "m.bot.command": { |
| 51 | + "syntax": "draupnir takedown {entity} {list} {reason}", |
| 52 | + "arguments": { |
| 53 | + "entity": { |
| 54 | + "id": "!room:example.org", |
| 55 | + "via": ["second.example.org"] |
| 56 | + }, |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +The bot will then respond with an event containing an `m.bot.command_prompt` mixin: |
| 63 | + |
| 64 | + |
| 65 | +```jsonc |
| 66 | +{ |
| 67 | + "body": "Please select a policy room", |
| 68 | + "m.bot.command_prompt": { |
| 69 | + "syntax": "draupnir takedown {entity} {list} {reason}", |
| 70 | + "arguments": { |
| 71 | + "entity": { |
| 72 | + "id": "!room:example.org", |
| 73 | + "via": ["second.example.org"] |
| 74 | + }, |
| 75 | + }, |
| 76 | + "suggested_arguments": { |
| 77 | + "list": { |
| 78 | + "suggested": [ |
| 79 | + { |
| 80 | + "id": "!policyroom:example.com", |
| 81 | + "via": ["second.example.com"] |
| 82 | + }, |
| 83 | + { |
| 84 | + "id": "!fTjMjIzNKEsFlUIiru:neko.dev", |
| 85 | + "via": ["neko.dev"] |
| 86 | + } |
| 87 | + ], |
| 88 | + "default": { |
| 89 | + "id": "!policyroom:example.com", |
| 90 | + "via": ["second.example.com"] |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +It is desirable that a bot can send a prompt without any prior command, so that it is possible to |
| 99 | +create notices which prompt action. |
| 100 | + |
| 101 | +### Client considerations |
| 102 | + |
| 103 | +Clients should allow prompts to be cancellable. |
| 104 | + |
| 105 | +## Potential issues |
| 106 | + |
| 107 | +None considered. |
| 108 | + |
| 109 | +## Alternatives |
| 110 | + |
| 111 | +### Reaction based prompts |
| 112 | + |
| 113 | +[Draupnir](https://github.com/the-draupnir-project/Draupnir) currently manages prompts manually by |
| 114 | +embedding a mixin in a reply to a command event with suggestsions that can be selected by sending |
| 115 | +a reaction that references the event. |
| 116 | + |
| 117 | +## Security considerations |
| 118 | + |
| 119 | +### Unsolicited prompt |
| 120 | + |
| 121 | +Clients need to take care to make sure that the sender of the prompt matches the bot for which the |
| 122 | +command is intended to be sent to. Otherwise clients could be tricked into sending commands by other |
| 123 | +users. |
| 124 | + |
| 125 | +## Unstable prefix |
| 126 | + |
| 127 | +`m.bot.command_prompt` -> `org.matrix.msc0000.command_prompt` |
| 128 | + |
| 129 | +## Dependencies |
| 130 | + |
| 131 | +This MSC builds on MSC4332 (which at the time of writing have not yet been accepted into the spec). |
0 commit comments