Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persisted interaction workflow state (redux sessions) #4

Open
andycmaj opened this issue Jun 29, 2019 · 0 comments
Open

persisted interaction workflow state (redux sessions) #4

andycmaj opened this issue Jun 29, 2019 · 0 comments

Comments

@andycmaj
Copy link
Owner

andycmaj commented Jun 29, 2019

Summary

use a redux-like state-persistence and updating mechanism.
hydrate and dehydrate state before and after each action runs.

so an HTTP request ~= a redux action.

Idea

Here's an interaction message sent from Slack and handled by a lambda:

{
  "type": "block_actions",
  "team": { ... },
  "user": { ... },
  "api_app_id": "API_APP_ID",
  "token": "MESSAGE_TOKEN",
  "container": {
    "type": "message",
    "message_ts": "1561776627.000500",
    "channel_id": "CHANNEL_ID",
    "is_ephemeral": false
  },
  "trigger_id": "679602909028.575391407056.10172fae809593326ff92c15c4db964d",
  "channel": { ... },
  "message": {
    "type": "message",
    "subtype": "bot_message",
    "text": "This+content+can't+be+displayed.",
    "ts": "1561776627.000500",
    "bot_id": "BOT_ID",
    "blocks": [
      {
        "type": "section",
        "block_id": "P4NT",
        "text": {
          "type": "mrkdwn",
          "text": "Progress:+\u2593\u2593\u2591\u2591\u2591",
          "verbatim": false
        },
        "accessory": {
          "type": "button",
          "action_id": "doAThing",
          "text": { "type": "plain_text", "text": "Go!", "emoji": true }
        }
      }
    ]
  },
  "response_url": "RESPONSE_URL",
  "actions": [
    {
      "action_id": "doAThing",
      "block_id": "P4NT",
      "text": { "type": "plain_text", "text": "Go!", "emoji": true },
      "type": "button",
      "action_ts": "1561776635.121684"
    }
  ]
}
  • slack do interaction
  • handle request
  • hydrate state into store
    • look up current state in distributed cache using previous message's identifiers. block_id
  • dispatch action action_id + block_id or some combination of things from actions payload
  • run reducers to compute new state
  • persist new state with block_id
    • use trigger_id as new block_id
  • render message with new block_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant