1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-24 02:02:16 -05:00

new/reworked protoXEP Quick Response

This commit is contained in:
Tim Henkes 2020-04-20 19:25:44 +02:00
parent 357497d259
commit c09bf67b91
2 changed files with 212 additions and 168 deletions

View File

@ -1,168 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep><header>
<title>Simple Buttons</title>
<abstract>This specification provides a way to send simple buttons.</abstract>
&LEGALNOTICE;
<number>xxxx</number>
<status>ProtoXEP</status>
<type>Standards Track</type>
<sig>Standards</sig>
<dependencies>
<spec>XMPP Core</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>NOT_YET_ASSIGNED</shortname>
<author>
<firstname>Kim</firstname>
<surname>Alvefur</surname>
<email>zash@zash.se</email>
<jid>zash@zash.se</jid>
</author>
<revision>
<version>0.0.2</version>
<date>2018-09-30</date>
<initials>ka</initials>
<remark>Polishing preparing for submission</remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2018-09-02</date>
<initials>ka</initials>
<remark>Initial version</remark>
</revision>
</header>
<section1 anchor="intro" topic="Introduction">
<p>Having actionable buttons in chats is apparently a fashionable thing
now. This specification defines a simple protocol for buttons and
responses.</p>
</section1><section1 anchor="reqs" topic="Requirements">
<ul>
<li>To provide a representation of a simple button or two in a chat.</li>
</ul>
<section2 anchor="todo" topic="TODO">
<ul>
<li>Is "button" too UI-centric?
<ul>
<li>Could base it on the <tt>&lt;action&gt;</tt> element from ad-hoc?</li>
</ul></li>
<li>Styling? Maybe a few fixed styles like normal, warning, danger?</li>
</ul>
</section2></section1><section1 anchor="glossary" topic="Glossary">
<p>OPTIONAL.</p>
<dl>
<di><dt>Button</dt>
<dd>An actionable object that can be invoked.</dd></di>
<di><dt>Click</dt>
<dd>The act of invoking the actionable object.</dd></di>
</dl>
</section1><section1 anchor="usecases" topic="Use Cases">
<p>A chat bot wants to provide fixed choice answers or commands.</p>
</section1><section1 anchor="elements" topic="Elements">
<section2 anchor="button-element" topic="Button element">
<p>A button is represented by a <tt>&lt;button&gt;</tt> element in the
<tt>urn:xmpp:tmp:buttons</tt>.</p>
<example><![CDATA[<button xmlns="urn:xmpp:tmp:buttons" value="button-clicked">
<label xml:lang="en">Click me</label>
</button>]]></example>
<dl>
<di><dt>value</dt>
<dd>Textual payload to be sent in a message <tt>&lt;body&gt;</tt> when the button is
clicked.</dd></di>
<di><dt>&lt;label&gt;</dt>
<dd>Text label for the button. Can be repeated per language.</dd></di>
</dl>
</section2></section1><section1 anchor="protocol" topic="Protocol">
<section2 anchor="sending-a-button" topic="Sending a button">
<p>A message with buttons is sent by including one or more &lt;button&gt;
elements with distinct value attributes. At least one &lt;label&gt; element
MUST be included containing a textual description for the button.</p>
<example><![CDATA[<message from="memberbot@example.com">
<body xml:lang="en">Approve? (yes/no)</body>
<button xmlns="urn:xmpp:tmp:buttons" value="yes">
<label xml:lang="en">Yes</label>
<label xml:lang="sv">Ja</label>
</button>
<button xmlns="urn:xmpp:tmp:buttons" value="no">
<label xml:lang="en">No</label>
<label xml:lang="sv">Nej</label>
</button>
</message>]]></example>
<p>A single message MUST NOT have multiple buttons with the same <tt>@value</tt>.</p>
</section2><section2 anchor="clicking-a-button" topic="Clicking a button">
<p>When the user clicks a button, their client sends a plain text message
body containing the <tt>@value</tt> as &lt;body&gt; text.</p>
<example><![CDATA[<message to="memberbot@example.com">
<body>yes</body>
</message>]]></example>
</section2></section1><section1 anchor="rules" topic="Business Rules">
<p>OPTIONAL. TODO.</p>
</section1><section1 anchor="impl" topic="Implementation Notes">
<p>OPTIONAL. TODO.</p>
</section1><section1 anchor="access" topic="Accessibility Considerations">
<p>Accessibility for whom?</p>
</section1><section1 anchor="i18n" topic="Internationalization Considerations">
<p>Multiple instances of the <tt>&lt;label/&gt;</tt> element MAY be included for the
purpose of providing alternate versions of the same text in different
languages, i.e. with distinct <tt>xml:lang</tt> attributes.</p>
</section1><section1 anchor="security" topic="Security Considerations">
<p>Do not press the big red button marked "Danger: Do Not Push".</p>
</section1><section1 anchor="iana" topic="IANA Considerations">
<p>None.</p>
</section1><section1 anchor="registrar" topic="XMPP Registrar Considerations">
<p>Register the namespace etc.</p>
</section1><section1 anchor="schema" topic="XML Schema">
<p>REQUIRED for protocol specifications.</p>
<code><![CDATA[button
@value : string
label+ : string]]></code>
</section1>
</xep>

212
inbox/quick-response.xml Normal file
View File

@ -0,0 +1,212 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM "xep.ent">
<!ENTITY ns "urn:xmpp:tmp:quick-response">
<!ENTITY xepname "Quick Response">
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>&xepname;</title>
<abstract>Quickly respond to automated messages.</abstract>
&LEGALNOTICE;
<number>xxxx</number>
<status>ProtoXEP</status>
<type>Standards Track</type>
<sig>Standards</sig>
<dependencies>
<spec>XMPP Core</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>NOT_YET_ASSIGNED</shortname>
<author>
<firstname>Kim</firstname>
<surname>Alvefur</surname>
<email>zash@zash.se</email>
<jid>zash@zash.se</jid>
</author>
<author>
<firstname>Tim</firstname>
<surname>Henkes</surname>
<email>me@syndace.dev</email>
</author>
<revision>
<version>0.1.0</version>
<date>2020-04-20</date>
<initials>th</initials>
<remark>
<ul>
<li>Renamed to better reflect the use-case</li>
<li>Split into two use-cases, one for textual responses and one for quick access to actions</li>
<li>Clarified i18n and general behavioral details</li>
</ul>
</remark>
</revision>
<revision>
<version>0.0.2</version>
<date>2018-09-30</date>
<initials>ka</initials>
<remark>Polishing preparing for submission</remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2018-09-02</date>
<initials>ka</initials>
<remark>Initial version</remark>
</revision>
</header>
<section1 anchor="intro" topic="Introduction">
<p>Interactions with bots often require sending one of multiple predefined (plaintext) messages. This specification offers a way for XMPP entities to list the accepted responses to a message, so that entities that receive such a list can offer convenient UI to quickly respond with one of the allowed responses. Additionally, this specification provides a way for entities to provide generic actions in similar fashion to quick responses.</p>
</section1>
<section1 anchor="reqs" topic="Requirements">
<ul>
<li>Offer a simple way to list allowed responses to a message.</li>
<li>Offer a solution that doesn't rely on the receiving device to support &xepname;.</li>
<li>Allow internationalized responses.</li>
</ul>
</section1>
<section1 anchor="usecases" topic="Use Cases">
<p>A chat bot wants to provide a list of allowed responses to a message it sends.</p>
<p>A chat bot wants to provide quick access to certain actions for convenience.</p>
</section1>
<section1 anchor="elements" topic="Elements">
<section2 anchor="allowed-response-element" topic="Allowed Response">
<p>Each allowed response is represented by an <tt>&lt;allowed-response&gt;</tt> element in the <tt>&ns;</tt> namespace.</p>
<example><![CDATA[<allowed-response xmlns="]]>&ns;<![CDATA[">
<translation xml:lang="en" value="yes" label="Yes!" />
<translation xml:lang="sv" value="ja" label="Ja!" />
</allowed-response>]]></example>
<dl>
<di>
<dt>&lt;translation&gt;</dt>
<dd>One for each <tt>&lt;body&gt;</tt> and <tt>@xml:lang</tt> included in the <tt>&lt;message&gt;</tt> this response is a part of. The <tt>@value</tt> is the internationalized textual payload to put into the <tt>&lt;body&gt;</tt> of the message stanza that is sent when this response is selected. The <tt>@label</tt> is an optional internationalized textual label for this response. Clients that offer UI for quick selection of one of the allowed responses MAY refer to this response by label instead of value.</dd>
</di>
</dl>
</section2>
<section2 anchor="available-action-element" topic="Available Action">
<p>Each available action is represented by an <tt>&lt;available-action&gt;</tt> element in the <tt>&ns;</tt> namespace.</p>
<example><![CDATA[<available-action xmlns="]]>&ns;<![CDATA[" id="merge">
<label xml:lang="en">Merge Now!</label>
</available-action>]]></example>
<dl>
<di><dt>@id</dt><dd>A string identifying the action. When selected, this id is sent in an <tt>&lt;action-selected&gt;</tt> element as part of a message stanza without any <tt>&lt;body&gt;</tt> elements.</dd></di>
<di><dt>&lt;label&gt;</dt><dd>Internationalized textual label for this action. One with the same <tt>@xml:lang</tt> of each <tt>&lt;body&gt;</tt> included in this <tt>&lt;message&gt;</tt>.</dd></di>
</dl>
</section2>
<section2 anchor="action-selected-element" topic="Action Selection">
<p>A selected action is represented by an <tt>&lt;action-selected&gt;</tt> element in the <tt>&ns;</tt> namespace.</p>
<example><![CDATA[<action-selected xmlns="]]>&ns;<![CDATA[" id="merge" />]]></example>
<dl>
<di><dt>@id</dt><dd>The id of the selected action, as defined in the selected <tt>&lt;available-action&gt;</tt>.</dd></di>
</dl>
</section2>
</section1>
<section1 anchor="protocol" topic="Protocol">
<section2 anchor="sending-allowed-responses" topic="Sending a Set of Allowed Responses">
<p>A message with allowed responses is sent by including one or more <tt>&lt;allowed-response&gt;</tt> elements with distinct values.</p>
<example><![CDATA[<message from="rootbot@example.com">
<body xml:lang="en">Execute `rm -rf /`? (yes/no)</body>
<allowed-response xmlns="]]>&ns;<![CDATA[">
<translation xml:lang="en" value="yes" label="Sure!" />
</allowed-response>
<allowed-response xmlns="]]>&ns;<![CDATA[">
<translation xml:lang="en" value="no" label="Uuuuuuh..." />
</allowed-response>
</message>]]></example>
<p>A single message MUST NOT contain multiple <tt>&lt;translation&gt;</tt> elements with the same values for both <tt>@xml:lang</tt> and <tt>@value</tt>. The same applies for the combination of <tt>@xml:lang</tt> and <tt>@label</tt>.</p>
<p>Clients that receive a message containing allowed responses can offer UI to quickly and conveniently select one of the allowed responses.</p>
</section2>
<section2 anchor="selecting-a-response" topic="Selecting a Response">
<p>When the user selects a response, their client sends a plaintext message body containing the <tt>@value</tt> as <tt>&lt;body&gt;</tt> text. The client uses the <tt>@value</tt> that corresponds to the <tt>&lt;translation&gt;</tt> of the same language as the <tt>&lt;body&gt;</tt>.</p>
<example><![CDATA[<message to="rootbot@example.com">
<body xml:lang="en">no</body>
</message>]]></example>
<p>The sender of the original message, in this example <tt>rootbot@example.com</tt>, checks incoming messages for a <tt>&lt;body&gt;</tt> that only contains the <tt>@value</tt> of the corresponding <tt>&lt;translation&gt;</tt> to see if a response was selected. In this example, the <tt>&lt;body&gt;</tt> matches the <tt>@value</tt> of the english translation for the response "No".</p>
</section2>
<section2 anchor="sending-available-actions" topic="Sending a Set of Available Actions">
<p>A message with available actions is sent by including one or more &lt;available-action&gt; elements with distinct <tt>@id</tt>s.</p>
<example><![CDATA[<message to="gitbot@example.com">
<body xml:lang="en">New merge request opened by ExampleUser: https://git.example.com/example/mrs/3/</body>
<available-action xmlns="]]>&ns;<![CDATA[" id="merge">
<label xml:lang="en">Merge Now</label>
</available-action>
</message>]]></example>
<p>A single message MUST NOT contain multiple <tt>&lt;available-action&gt;</tt> elements with the same values for the <tt>@id</tt> attribute. Labels MUST be unique per id and language.</p>
<p>Clients that receive a message containing available actions SHOULD offer UI to select one of the actions.</p>
</section2>
<section2 anchor="selecting-an-action" topic="Selecting an Action">
<p>When the user selects an action, their client sends a message containing an <tt>&lt;action-selected&gt;</tt> element which identifies the selected action. The message does not contain a <tt>&lt;body&gt;</tt>.</p>
<example><![CDATA[<message to="gitbot@example.com">
<action-selected xmlns="]]>&ns;<![CDATA[" id="merge" />
</message>]]></example>
</section2>
</section1>
<section1 anchor="rules" topic="Business Rules">
<p>All message bodies SHOULD always list the (internationalized) allowed responses too, so that users of clients that don't support &xepname; can still know what the allowed responses are.</p>
<p>Bots or other entities that indicate allowed responses are free to accept variations of the response values for convenience, for example ignoring the casing or accepting abbreviations of response values.</p>
<p>Actions SHOULD only be a quicker way to access a feature that could also be accessed using information in the message body. For example, a bot that notifies about a new merge request includes in its notification message body a link to the web interface where manual merging is possible. An action could offer a more convenient way to merge, without taking the route via the web interface. In summary, users of clients that don't support &xepname; SHOULD still have a way to manually trigger the action.</p>
<p>Clients MUST only provide quick responses for the most recently received message that contains text content.</p>
<p>Clients MUST only provide action selection for the most recently received message that contains actions. This is slightly different than the rule for quick responses, in that the message defining the action does not have to be the most recent message with text content, but only the most recent message that contains actions.</p>
<p>Clients MAY decide to not offer action selection if the message containing the action is not the most recent message with text content.</p>
<p>It is up to the client and its specific UI requirements to decide what to do if both quick responses and actions are available, potentionally coming from different messages.</p>
</section1>
<section1 anchor="access" topic="Accessibility Considerations">
<p>The elements introduced in this specification carry clear semantics that allow clients to implement UI flexibly for their target user group and hardware platform capabilites.</p>
</section1>
<section1 anchor="i18n" topic="Internationalization Considerations">
<p>All elements introduced in this specification require internationalizing plaintext content to be consistent with the language of all message <tt>&lt;body&gt;</tt> elements.</p>
</section1>
<section1 anchor="security" topic="Security Considerations">
<p>This specification only adds quicker/more convenient access to features that are accessible anyway.</p>
</section1>
<section1 anchor="iana" topic="IANA Considerations">
<p>This document requires no interaction with the Internet Assigned Numbers Authority (IANA).</p>
</section1>
<section1 anchor="registrar" topic="XMPP Registrar Considerations">
<section2 anchor="namespaces" topic="Protocol Namespaces">
<p>This specification defines the following XMPP namespaces:</p>
<ul>
<li>&ns;</li>
</ul>
</section2>
<section2 anchor="versioning" topic="Protocol Versioning">
&NSVER;
</section2>
</section1>
<section1 anchor="schema" topic="XML Schema">
<code>TODO</code>
</section1>
</xep>