Skip to content

Instantly share code, notes, and snippets.

@cunla
Last active March 24, 2022 02:45
Show Gist options
  • Save cunla/d1e775ca9dc3231a94b0f8bedec58fd2 to your computer and use it in GitHub Desktop.
Save cunla/d1e775ca9dc3231a94b0f8bedec58fd2 to your computer and use it in GitHub Desktop.
scan slack for Q&A and post drafts to wiwik

Design to collect Q&A from slack

Assumptions

  • All information for one question and answer is under one thread in slack.
  • The author of the first message in a thread is identified as the question author.
  • Any other messages by the author of the first message are clarifications and should be added to the question body.
  • The last message in the thread which is not by the question author is the the accepted answer.
  • It is possible to collect all threads from a slack channel with the relevant information:
    • message text
    • message author
    • reactions to messages (likes, thank you, etc.)
    [{
      "threadid": "..."
      "messages": [{
          "author_user_name": "danielmo",
          "content": "hi, i've got a customer seeing this error on startup in a BaaS installation - Does this ring a bell to anyone? ```2022-03-15 15:01:42,608 ERROR [org.key.con.jpa.upd.liq.con.DefaultLiquibaseConnectionProvider] (main) Change Set META-INF/jpa-changelog-1.9.1.xml::1.9.1::keycloak failed.  Error: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs [Failed SQL: ALTER TABLE `identity-backbaseidentity`.REALM MODIFY CERTIFICATE VARCHAR(4000)]",
        }, {     
          "author_user_name": "robinson",
          "content": "They created their own schema, and now they are ...",
        }, {msg...}
      ]
    }, {thread2...}
    ]

Scan and generate drafts sequence diagram

sequenceDiagram
    participant scan as scan-app
    participant slack as slack channel
    participant user as Person
    participant wiwik as wiwik
    
    scan ->>+ slack: get messages from date
    note left of slack: Array of threads,<br/>each message in thread should have<br/>the author, the text and the likes
    slack -->>- scan: messages json
    
    loop for each thread
        scan ->> scan: Generate markdown with <br/> all messages with thread original author <br/> keep as question text
        scan ->> scan: Find last message not by thread original author <br/> keep as answer
        scan ->>+ wiwik: Create draft: <br/>question by original author<br/>
        wiwik ->> wiwik: Create users if do not exist
        wiwik ->> wiwik: Create question draft
        wiwik -->>- scan: draft url/id
        scan ->>+ slack: Send link of draft to both users <br/> (original user who asked + user who answered)
    end


Loading

Approve draft sequence

sequenceDiagram
    user --> slack: view message with draft url and click
    user ->>+ wiwik: view/edit draft, save
    wiwik -->>- user: ack
    user ->>+ wiwik: Approve draft
    wiwik ->> wiwik: Create searchable post,<br/> with accepted answer
    wiwik ->>- user: ack
Loading

Drafts API design

Create draft: POST /drafts

{
  "question": {
    "author": "author@email.com",
    "content": "markdown content",
    "title": "title"
  },
  "answer": {
    "author": "author@email.com",
    "content": "markdown content",
  },
}

Response: Http201

{
  "url": "/drafts/{draftId}"
  "id": "..."
}

Approve draft: POST /drafts/{draftId}/approve/

Response:

  • If all ok, Http200
{
  "url": "/questions/{questionId}"
}
  • If missing info: Http422
{
  "errors": ["Missing title", "Missing author", "Missing ..."]
}

Discard draft: DELETE /drafts/{draftId}/discard/

Response: Http200

Action items

  • wiwik: Support creating drafts, approving drafts (i.e., convert to question&answer), discarding drafts
  • slack scanner
  • get hook to allow scanning of specific channels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment