Developer Guides
Handling output

Handling Output

When the user interacts with your app, the AI generates a JSON object in response that conforms to the schema you defined. The user can view a visualized version of the JSON object on the right side of the screen. In the previous sections, you learned how to define the schema and customize the UI. In this section, you'll learn how to handle the output generated by the AI.

When the user feels satisfied with the output, they can click the action button to save the output. The output can vary depending on your app's settings.

A screenshot of the app settings tab showing how to change the handling method

You can choose from the following handling methods:

  • View only: The user can just view the output.
  • Download JSON: The user can download the JSON object.
  • Send to HTTP endpoint: This is the method you'll use to send the AI output to your server if you want to generate the ultimate output. For example, a video, a PDF, a document or any other output that requires processing.

Send to HTTP endpoint

When you choose the Send to HTTP endpoint method, you need to provide the URL of the endpoint where you want to send the output and a label for the button that the user will click to send the output.

When the user clicks the button, the user will be redirected to the endpoint URL with the chat session ID, sid as a query parameter. The endpoint can then use the chat session ID to fetch the JSON object from the Flowformer API.

A screenshot of the app settings tab showing the HTTP endpoint settings

To fetch the contract JSON object from the Flowformer API, you can make a simple GET request to the following URL:

https://flowformer.app/api/rest/v1/sessions?sid=<chat-session-id>&app_id=<app-id>

Example response

{
  "session": {
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "createdAt": "2024-04-22T22:48:32.374Z"
  },
  "contract": {
    "$type": "Presentation",
    "title": "The Art of Martial Arts",
    "slides": [
      {
        "$type": "SingleImageSlide",
        "title": "Introduction to Martial Arts",
        "narration": "Martial arts have a rich history dating back centuries. They encompass a variety of combat and self-defense techniques practiced for physical, mental, and spiritual development.",
        "queryForImage": "Very serious-looking male martial artist",
        "generatedImage": "https://flowformer-assets-dev.s3.amazonaws.com/d3fb5e98-34ef-47fb-8c5d-1b61a914d539.png"
      },
      {
        "$type": "BulletPointSlide",
        "title": "Popular Martial Arts Styles",
        "narration": "There are numerous martial arts styles practiced worldwide, each with its unique techniques and philosophies. Some popular styles include Karate, Taekwondo, Judo, and Kung Fu.",
        "bulletPoints": [
          "Karate emphasizes striking techniques",
          "Taekwondo focuses on high kicks and fast movements",
          "Judo is known for throws and grappling techniques",
          "Kung Fu incorporates a wide range of fighting styles"
        ]
      },
      {
        "$type": "TitleOnlySlide",
        "title": "Benefits of Practicing Martial Arts",
        "narration": "Engaging in martial arts training offers a wide range of benefits, including improved physical fitness, enhanced self-discipline, increased self-confidence, and stress relief."
      }
    ]
  }
}

Since the JSON object is guaranteed to conform to the schema you defined, you can write code to process the JSON object and generate the ultimate output. For example, you can write code to transform the JSON object above into a PPTX documents.

A screenshot of the chat page in the studio