Generate or update a flow

POST /flows

Query parameters

  • format string

    The desired format for the generated flow

    Values are xstate or fragments. Default value is xstate.

  • output-mode string

    Whether to produce an incremental flow (excluding the existing flow) or a full flow

    Values are full or incremental. Default value is incremental.

Body

  • text string Required

    The text description of the flow we should generate

  • context string

    The broader context that should be used to interpret text.

    For example, if a user writes:

    After users log in, bring them to the home page
    

    and then continues:

    Then, if it's their first visit, show them a popup
    

    Providing After users log in... as context when passing Then, ... as the text will result in the correct interpretation of the source state for showing the popup.

    The context will not contribute to any new transitions. It will only be used to properly interpret text.

  • existingFlow object

    One of:

Responses

  • 200

    The requested flow

    Hide response attributes Show response attributes object
    • id string Required

      Response identifier to be used in error reporting, debugging, and feedback

    • result object Required

      One of:
POST /flows
curl \
 -X POST https://api.flow.simplystated.dev/flows \
 -H "x-api-key: $API_KEY" \
 -H "Content-Type: application/json" \
 -d '{"text":"Open the search autocomplete when the user hovers or focuses in the search box","context":"After users log in, bring them to the home page\n","existingFlow":{"format":"xstate","flow":{"description":"string","on":{"click":[{"cond":"Is valid","target":"Submit","actions":["Show notification"]}]},"after":[{"delay":500,"target":"Timed out","actions":["Show timeout notification"]}],"always":[{"description":"string","cond":"isValid","target":"idle","actions":["sendTelemetry"]}],"entryActions":["sendTelemetry"],"exitActions":["sendTelemetry"],"invoke":[{"src":"saveUser","onDone":[{"description":"string","cond":"isValid","target":"idle","actions":["sendTelemetry"]}],"onError":[{"description":"string","cond":"isValid","target":"idle","actions":["sendTelemetry"]}]}],"states":{}}}}'
Request example
{
  "text": "Open the search autocomplete when the user hovers or focuses in the search box",
  "context": "After users log in, bring them to the home page\n",
  "existingFlow": {
    "format": "xstate",
    "flow": {
      "description": "string",
      "on": {
        "click": [
          {
            "cond": "Is valid",
            "target": "Submit",
            "actions": [
              "Show notification"
            ]
          }
        ]
      },
      "after": [
        {
          "delay": 500,
          "target": "Timed out",
          "actions": [
            "Show timeout notification"
          ]
        }
      ],
      "always": [
        {
          "description": "string",
          "cond": "isValid",
          "target": "idle",
          "actions": [
            "sendTelemetry"
          ]
        }
      ],
      "entryActions": [
        "sendTelemetry"
      ],
      "exitActions": [
        "sendTelemetry"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ]
        }
      ],
      "states": {}
    }
  }
}
Request examples
{
  "text": "Open the search autocomplete when the user hovers or focuses in the search box",
  "context": "After users log in, bring them to the home page\n",
  "existingFlow": {
    "format": "xstate",
    "flow": {
      "description": "string",
      "on": {
        "click": [
          {
            "cond": "Is valid",
            "target": "Submit",
            "actions": [
              "Show notification"
            ]
          }
        ]
      },
      "after": [
        {
          "delay": 500,
          "target": "Timed out",
          "actions": [
            "Show timeout notification"
          ]
        }
      ],
      "always": [
        {
          "description": "string",
          "cond": "isValid",
          "target": "idle",
          "actions": [
            "sendTelemetry"
          ]
        }
      ],
      "entryActions": [
        "sendTelemetry"
      ],
      "exitActions": [
        "sendTelemetry"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ]
        }
      ],
      "states": {
        "Additional properties:": {
          "description": "string",
          "on": {
            "click": [
              {
                "cond": "Is valid",
                "target": "Submit",
                "actions": [
                  "Show notification"
                ]
              }
            ]
          },
          "after": [
            {
              "delay": 500,
              "target": "Timed out",
              "actions": [
                "Show timeout notification"
              ]
            }
          ],
          "always": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "entryActions": [
            "sendTelemetry"
          ],
          "exitActions": [
            "sendTelemetry"
          ],
          "invoke": [
            {
              "src": "saveUser",
              "onDone": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "sendTelemetry"
                  ]
                }
              ],
              "onError": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "sendTelemetry"
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
}
Response examples (200)
{
  "id": "string",
  "result": {
    "format": "xstate",
    "flow": {
      "description": "string",
      "on": {
        "click": [
          {
            "cond": "Is valid",
            "target": "Submit",
            "actions": [
              "Show notification"
            ]
          }
        ]
      },
      "after": [
        {
          "delay": 500,
          "target": "Timed out",
          "actions": [
            "Show timeout notification"
          ]
        }
      ],
      "always": [
        {
          "description": "string",
          "cond": "isValid",
          "target": "idle",
          "actions": [
            "sendTelemetry"
          ]
        }
      ],
      "entryActions": [
        "sendTelemetry"
      ],
      "exitActions": [
        "sendTelemetry"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ]
        }
      ],
      "states": {}
    }
  }
}
Response examples (200)
{
  "id": "string",
  "result": {
    "format": "xstate",
    "flow": {
      "description": "string",
      "on": {
        "click": [
          {
            "cond": "Is valid",
            "target": "Submit",
            "actions": [
              "Show notification"
            ]
          }
        ]
      },
      "after": [
        {
          "delay": 500,
          "target": "Timed out",
          "actions": [
            "Show timeout notification"
          ]
        }
      ],
      "always": [
        {
          "description": "string",
          "cond": "isValid",
          "target": "idle",
          "actions": [
            "sendTelemetry"
          ]
        }
      ],
      "entryActions": [
        "sendTelemetry"
      ],
      "exitActions": [
        "sendTelemetry"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ]
        }
      ],
      "states": {
        "Additional properties:": {
          "description": "string",
          "on": {
            "click": [
              {
                "cond": "Is valid",
                "target": "Submit",
                "actions": [
                  "Show notification"
                ]
              }
            ]
          },
          "after": [
            {
              "delay": 500,
              "target": "Timed out",
              "actions": [
                "Show timeout notification"
              ]
            }
          ],
          "always": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "sendTelemetry"
              ]
            }
          ],
          "entryActions": [
            "sendTelemetry"
          ],
          "exitActions": [
            "sendTelemetry"
          ],
          "invoke": [
            {
              "src": "saveUser",
              "onDone": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "sendTelemetry"
                  ]
                }
              ],
              "onError": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "sendTelemetry"
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
}