nips icon indicating copy to clipboard operation
nips copied to clipboard

Surveys/polls

Open fernandolguevara opened this issue 3 years ago • 3 comments

we could add a new to tag to allow creation of surveys/polls on nostr protocol

// create
tag: surv
options:
 - <multi|single> allow others to reply with one or multiple options
 - <ttl> TTL (in seconds|timestamp) when surv expires
 - [<choice>]: up to 4 choices each limited to 25 chars  

// reply 
tag: surv-resp
options:
 - [<choice>]: based on surv type it can have one or multi
{
    "pubkey": "<pub-key>",
    "created_at": 1000000000,
    "kind": 1,
    "tags": [
      ["t", "hastag"],
      ["surv", "<multi|single>", "<ttl>", "choice 1", "choice 2"]
    ],
    "content": "#hastag what is your favorite ...?\n",
    "id": "<event-id>"
  },
  {
    "pubkey": "<pub-key>",
    "created_at": 1000000000,
    "kind": 1,
    "tags": [
      ["p", "<pub-key-root>", "wss://..."],
      ["e", "<event-id-root>", "wss://...", "root"],
      ["t", "tag"],
      ["surv-resp", "choice 1", ...] // based on root event surv type it can have one or multi 
    ],
    "content": "hello #tag\n",
    "id": "<event-id>"
  }

fernandolguevara avatar Nov 11 '22 17:11 fernandolguevara

I think polls would be really nice to have. small comment, i think any response to the poll should list the poll event as the "root" and not "reply" in the event tag

monlovesmango avatar Nov 26 '22 21:11 monlovesmango

A few thoughts:

  1. You would need to assign a different kind number (?)
  2. The marker on the e tag in the reply should be "reply", if my interpretation of nip 10 is correct.
  3. I would split surv and choice, and introduce choice as an additional separate tag, with two attributes, index (optional) and text (mandatory)

examples: ["choice", 0, "Option # 1"] ["choice", "Option # 2" ]

  1. Minimum of two choice tags.
  2. In the reply, we include the respondent's selected choice tags (minimum 1) in the tag list.
  3. One vote per key. The relay needs to discard all subsequent votes, as well as invalid replies.

tcheeric avatar Dec 14 '22 03:12 tcheeric

@tcheeric for #2 it should be 'root' not 'reply'. the marker identifies the event that is tagged. the event that is tagged is a root event, not a reply event. I have a pr open to clarify top level replies for nip 10.

https://github.com/nostr-protocol/nips/pull/80

monlovesmango avatar Dec 14 '22 04:12 monlovesmango