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.

application/json

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

    A flow

    One of:

Responses

  • 200 application/json

    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

      A flow

      One of:
POST /flows
curl \
 --request POST 'https://api.flow.simplystated.dev/flows' \
 --header "x-api-key: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"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":["string"]}],"entryActions":["string"],"exitActions":["string"],"invoke":[{"src":"saveUser","onDone":[{"description":"string","cond":"isValid","target":"idle","actions":["string"]}],"onError":[{"description":"string","cond":"isValid","target":"idle","actions":["string"]}]}],"states":{"*":{"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":["string"]}],"entryActions":["string"],"exitActions":["string"],"invoke":[{"src":"saveUser","onDone":[{"description":"string","cond":"isValid","target":"idle","actions":["string"]}],"onError":[{"description":"string","cond":"isValid","target":"idle","actions":["string"]}]}]}}}}}'
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": [
            "string"
          ]
        }
      ],
      "entryActions": [
        "string"
      ],
      "exitActions": [
        "string"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "string"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "string"
              ]
            }
          ]
        }
      ],
      "states": {
        "*": {
          "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": [
                "string"
              ]
            }
          ],
          "entryActions": [
            "string"
          ],
          "exitActions": [
            "string"
          ],
          "invoke": [
            {
              "src": "saveUser",
              "onDone": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "string"
                  ]
                }
              ],
              "onError": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "string"
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
}
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": [
            "string"
          ]
        }
      ],
      "entryActions": [
        "string"
      ],
      "exitActions": [
        "string"
      ],
      "invoke": [
        {
          "src": "saveUser",
          "onDone": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "string"
              ]
            }
          ],
          "onError": [
            {
              "description": "string",
              "cond": "isValid",
              "target": "idle",
              "actions": [
                "string"
              ]
            }
          ]
        }
      ],
      "states": {
        "*": {
          "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": [
                "string"
              ]
            }
          ],
          "entryActions": [
            "string"
          ],
          "exitActions": [
            "string"
          ],
          "invoke": [
            {
              "src": "saveUser",
              "onDone": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "string"
                  ]
                }
              ],
              "onError": [
                {
                  "description": "string",
                  "cond": "isValid",
                  "target": "idle",
                  "actions": [
                    "string"
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
}