Appfarm Documentation
Getting startedDocumentationCommunityAppfarm Create
  • Overview
  • Getting Started
    • What is Appfarm?
    • Key concepts
    • Quickstart
      • Speed intro
      • Step-by-step guide
    • Appfarm Showroom
    • FAQ
  • Appcademy
    • Learning paths
    • Appfarm Fundamentals
      • Intro Course
        • 1. Intro to No-Code and Appfarm
        • 2. Navigation in Appfarm Create
        • 3. What is Apps?
        • 4. Intro to UI Editor
        • 5. Data Model
        • 6. App Data
        • 7. Actions
        • 8. Tips and Tricks
        • 9. Intro to practical walkthrough
        • 10. Create a details view of a Project
        • 11. Create a Custom List
        • 12. Swipe and Delete
        • 13. Functionality for simple Create of Data
        • 14. Upload and Download Photos
        • 15. Input Dialog with Validation and Save
        • 16. Dashboard
        • 17. Summary
        • Quiz
      • User Interface Fundamentals
        • Container - Sectioning, Styling and Repeating
        • Conditional Styles
        • Motions
        • Responsive Design
        • Step-by-step workflow
        • Featured UI Components
        • Quiz
      • App Data Fundamentals
        • Data Source Filtering
        • App Variables and Runtime Properties
        • URL Parameters
        • Quiz
      • Actions & Logic Fundamentals
        • Event Handlers
        • Featured Action Nodes
        • Context Parameters
        • Quiz
      • Services Fundamentals
        • Introduction to Services
        • Setting up a Service
        • Scheduling a Service
      • Integration Fundamentals
        • The web request action node
        • Fetch data from an endpoint
        • Map data to a data source
        • Modify the response
        • Nested data mapping
        • Path parameters
        • Authentication
        • Send data to an endpoint
        • Quiz
      • User handling and permissions
        • Users and roles
        • Permissions
        • Creating users
        • Extending the User object class
        • Updating and deleting users
        • Unauthenticated access
        • Quiz
    • Appfarm Professional
      • User Interfaces
        • Featured UI Components
        • Concepts and Use Cases
      • Data Structures & Data Handling
        • Data Features
        • Search & Filters
        • Featured Action Nodes
        • GraphQL
      • Logic & Flow
        • Logical Concepts
        • Date and Time Handling
        • Featured Action Nodes
        • Exception Handling
      • Login & Configuration
        • Login and Authentication
        • Settings, Configuration and Languages
      • Security & Operations
        • Security and Permissions
        • Deployment
        • Schedules and Logs
        • Debugging and App Health
      • Performance & Optimization
        • Optimizing Performance
        • Enhancing Functionality
    • Appfarm Sales Representative
    • Appfarm Developer Forum
      • Session 1: Data Modeling in Appfarm Create
      • Session 2: App Data in Appfarm Create
      • Session 3: Services in Appfarm Create
      • Session 4: Optimizing Performance
    • Background
      • Databases
        • Data modeling 101
        • Database normalization
  • Library
    • UI components
      • Advanced bar chart
      • Advanced bubble chart
      • Advanced combined chart
      • Advanced gantt chart
      • Advanced heatmap chart
      • Advanced line/area chart
      • Advanced pie chart
      • Advanced scatter plot chart
      • Advanced solid gauge chart
      • Animated component
      • Avatar
      • Avatar group
      • Basic bar chart
      • Basic gauge chart
      • Basic line chart
      • Basic pie chart
      • Bottom navigation
      • Button
      • Checkbox
      • Chip group
      • Circular progress
      • Coded component
      • Container
      • Date & time picker
      • Drawable canvas
      • Floating action button
      • Icon
      • Icon button
      • Iframe
      • Image
      • Linear progress
      • List
      • Map
      • Menu list
      • Multi select
      • PDF reader
      • Popover
      • Radio buttons
      • Rich text editor
      • Rich text
      • Select
      • Slider
      • Speed dial
      • Switch
      • Table
      • Tabs
      • Text
      • Text edit
      • View container
      • Visibility group
    • Action nodes
      • Aggregate data
      • Advanced search
      • Auth operations
      • Block
      • Catch exception
      • Copy to clipboard
      • Create file archive
      • Create file object
      • Create object
      • Create user account
      • Delete objects
      • Delete user account
      • Duplicate objects
      • End execution
      • Exit block
      • Exit loop
      • Export data
      • Foreach
      • Generate document
      • If
      • Import data
      • Invalidate cache
      • Log in
      • Log to console
      • Log out
      • Next iteration
      • Navigate
      • Open/close popover
      • Open confirm dialog
      • Open print dialog
      • Open snackbar
      • Open Unsplash dialog
      • Open URL
      • Persist objects
      • Push notifications
      • Read objects
      • Request permissions
      • Run code
      • Run other action
      • Run service
      • Scan barcode/QR code
      • Send email
      • Send SMS
      • Set client language
      • Set data source attributes
      • Set selection
      • Set theme
      • Set user account image
      • Show install app prompt
      • Sleep
      • Sort objects
      • Throw exception
      • Toggle drawer
      • Update object
      • Update secret
      • Update user account
      • Web request
      • While
  • Reference
    • Appfarm Create
      • Appfarm Commander
      • Blue dots
      • Copy & Paste
      • Farmer's Market
      • Find references
      • Find usage
      • Keyboard shortcuts
      • Undo/Redo
      • User preferences
    • Platform concepts
      • Conditions
      • Data bindings
      • Date and time
      • Event handlers
      • Filters
      • Functions
      • Markdown
      • Objects
      • Operators
      • Value processor
    • Dashboard
    • Apps
      • UI
        • Views
          • Dialog
          • Drawer
        • Layout designer
        • Component properties
        • Shareable UI components
      • Data
        • App variables
        • Data sources
        • Calendar data sources
      • Actions
      • App settings
      • App size
      • App health
    • Services
      • Service Endpoints
      • Service settings
      • Service health
      • API explorer
    • Data model
      • Object classes
      • Object class properties
      • Enumerated types
      • GraphQL
        • Queries
        • Mutations
      • Data Extract API
      • Time series data
    • Operations
      • Deploy
      • Schedules
      • Logs
    • Resources
      • Themes
      • Files
      • Fonts
      • Internationalization
    • Configuration
      • Environments
      • Login
        • Custom auth providers
    • Security
      • Users
      • Service accounts
      • Roles
      • Secrets
      • Permissions
        • Conditional Permissions
    • Appfarm Client
      • Developer tools for Apps
      • Developer tools for Services
      • Warnings and errors
  • How to
    • Data modeling
      • Many-to-many relationships
      • Use naming conventions
      • Offline data handling
      • Data silos and White labelling
    • User interface
      • Manage a many-to-many relationship with a Chip group
      • Configure drag and drop
      • Build a drag-and-drop calendar
      • Design a responsive layout
      • Work with flexbox
      • Use Mapbox as a map layer
      • Understand charts
    • Logic and flow
      • Event Log Design
      • Configure advanced search
    • Themes and styling
      • Change the active theme
      • Add custom email templates
    • Enhance your app
      • Add deep links
      • Add keyboard shortcuts
      • Add link previews for social media
      • Apply SEO best practices
      • Change the active language
      • Generate a PDF from a Container
    • Integrations
      • Integrate with external systems
      • Integrate with OpenAI
      • Integrate with Google Analytics (GA4)
      • Configure a custom email account
      • Integrate with a payment provider
      • Integrate with Signicat
      • Integrate directly with an external database
      • Retrieve a Bearer token from Google Cloud
      • Fetch data from BigQuery
      • Retrieve access token from Microsoft Entra ID
    • Workflow automation
      • Update an OAuth 2.0 access token from a service
    • Authentication and access control
      • Add users and assign roles
      • Configure unauthenticated access
      • Implement third-party authentication
    • Security, testing and deployment
      • Add a custom domain
      • Install an app on a device
      • Get ready for Production
      • Optimize performance
      • Security checklist
      • Test and debug
    • Example apps
      • Create an Instagram clone
        • The end result
        • Designing the feed
        • Create new post
        • Add a like-button
        • Add comment-functionality
  • Solution administration
    • Subscription and billing
    • Dedicated tier benefits
    • Guide to GDPR
      • Key principles
      • How Appfarm protects personal data
      • How you can protect your clients’ data
      • Glossary
    • Appfarm and the EU AI Act
  • Policies
    • Appfarm Policies
    • Data Processors
    • Privacy Policy
Powered by GitBook
On this page
  • Getting Started
  • Setting up the integration in Appfarm Create
  • Implementing a use case (example)
  • Sending data to OpenAI
  • Analyze business data or files on demand
  • Analyze a large set of files

Was this helpful?

Export as PDF
  1. How to
  2. Integrations

Integrate with OpenAI

PreviousIntegrate with external systemsNextIntegrate with Google Analytics (GA4)

Last updated 10 days ago

Was this helpful?

ChatGPT is a conversational AI language model trained and designed to provide informative and engaging responses to users in natural language, and it supports multiple languages. It may be used in many different areas, such as customer service, education/training, personal assistants (summary, translations, planning), content creation, entertainment and programming.

ChatGPT is created by OpenAI. The application ChatGPT is just the application that is available to the public, and it operates on top of powerful Large Language Models (LLMs).

The great thing with OpenAI is that all of this is available through APIs. You may try the for free, but in general, it is pay-as-you-go.

The key to getting the most value out of Chat API is to design a (input/questions) in an optimal way. You may read more on prompt design .

A few showcases of OpenAI API integrations are found in our ! You may try the functionality, as well as access the setup in Appfarm Create. If you do not have access, you may register .

Getting Started

First off, you need to sign up (or login) at

Once inside, you have access to a lot of tutorials. But technically, you only need to go to your Account and locate the . Generate a new API key and store it somewhere safely (for example, as a in Appfarm Create).

The API we will be using in this example is the . It takes a prompt and a few parameters as input, and returns the response from OpenAI. In the below example, we use text only as input, but the API also supports images and files.

Setting up the integration in Appfarm Create

The integration is a simple web request.

In the above illustration:

  • Auth Token: The API Key from Open AI (stored as a secret, as mentioned in the Getting Started section above)

Body Content (the input to the API)

{
  "model": "gpt-4.1",
  "messages": [
      {"role": "system", "content": "Act as a professional chef"},
      {"role": "user", "content": "Give me your best lasagna recipe"}
      ],
  "temperature": 0.3,
  "max_tokens": 1000,
}
  • messages: Required. This is a list of messages describing the conversation so far. 3 Roles exist:

    • system: Typically, your conversation (list of messages) starts with a system message. This message helps you set the default behaviour or context of the "AI assistant".

    • user: this is the one instructing the assistant.

    • assistant: this helps you store previous responses. If you have a full conversation between the AI assistant and the user, you may input alternate messages between user and assistant, such as in this example:

      messages=[
              {"role": "system", "content": "You are a helpful assistant."},
              {"role": "user", "content": "Who won the world series in 2020?"},
              {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
              {"role": "user", "content": "Where was it played?"}
          ]
  • temperature: 0 means deterministic. You will get the same response for the same prompt each time. 1 is the opposite - OpenAI will take a higher risk and give you different responses each time. You may use something in between like 0.4 as well, depending on the use case

Response

The response contains more information that you would typically need to store or process. Example response of the above input is:

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "\n\nHello there, how may I assist you today?",
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

The textual output from the API is found in the choices node, and you may refer to this first entry in the Result Mapping choices.0.message.content

Implementing a use case (example)

What we do in this case, is to save the user input into App Variables Ingredients List and Servings.

We create the prompt by merging a question/prompt with the user inputs, as seen from the function below, where we construct the body (input) to the Completions API.

const prompt =  `Make a ${dinnerRecipe ? 'Dinner' : 'Dessert'} recipe for ${servings} people with the following ingredients as main components:
${ingrediensList}.

Also, use the metric system for all units.

`

return {
  "model": "gpt-4.1",
  "messages": [
      {"role": "system", "content": "Act as a professional chef"},
      {"role": "user", "content": prompt}
      ],
  "temperature": 0.3,
  "max_tokens": 1000,
}

As seen in the setup above, we also define a system as "Act as a professional chef".

The concept above is called Prompt Design. Tuning the wording of the prompt, combined with a good system definition, will allow you to take more control of the quality of the output from the API.

Sending data to OpenAI

In many business use cases, you may want to either

  1. Send files or business data "on-demand" together with the prompt.

    1. Example 1: Give me the business name, amount, and date from this receipt

    2. Example 2: Analyze these data records (represented as CSV). The list represents all action items of a project plan of an implementation project with the following project description and timelines: "....". Give me a list of suggested action items to add, represented as JSON.

  2. Uploads a large file or many files to a file storage, for the AI to use as a basis for its reasoning

    1. This is RAG (Retrieval Augmented Generation), where the files are uploaded (and chunked) into a vector store, and you can enable a file-search tool in the API - enabling the AI to search for relevant information to be used together with the prompt.

    2. Example 3: You are an assistant for our in-house HR department. Use file search to provide the user with an answer to the user query. Always ground your reasoning in these files. If you cannot find an answer in the files, inform the user, and give an answer based on best practices and current legislation.

Analyze business data or files on demand

  • For sending an image, see the following example

{
    "model": "gpt-4.1",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Give me the business name, amount, and date from this receipt"
          },
          {
            "type": "image",
            "image_url": {
              "url": "URL to the image here"
            }
          }
        ]
      }
    ],
    "max_tokens": 3000
}
{
    "model": "gpt-4.1",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Give me the business name, amount, and date from this receipt"
          },
          {
            "type": "file",
            "file": {
              "file_data": "base64 string here",
              "file_name": "MyReceipt.pdf"
            }
          }
        ]
      }
    ],
    "max_tokens": 3000
}
  • For sending CSV or other file formats, they must be converted to a string, and passed along with the prompt as a text message. You may convert a data source (holding all entries you want to analyze) to a CSV string with the following function (example):

// Example for creating a CSV representation of the data source "projects"
// "projects" has been added as a function parameter

if (!Array.isArray(projects) || projects.length === 0) return "";

// Collect all unique keys across all projects
const allKeys = Array.from(
    new Set(projects.flatMap(project => Object.keys(project)))
);

// Create header row
const header = allKeys.join(";");

// Create data rows
const rows = projects.map(project => {
    return allKeys.map(key => {
        const value = project[key];
        if (value === undefined || value === null) return '""';
        if (typeof value === "string") return `"${value.replace(/"/g, '""')}"`;
        return value;
    }).join(";");
});

// Combine header and rows
return [header, ...rows].join("\n");

Analyze a large set of files

For this purpose, you should do the following

URL:

You may read more about these and additional parameters . The most important parameters are:

model: Required. The ID of the model to use. See the overview .

max_tokens: The number of "words". OpenAI operates with its own term here, where a is similar to a word, but a token may be smaller as well.

Our Appfarm Showroom showcase - "" - is an App for entering a list of ingredients and getting a suggestion of a dinner matching those ingredients. The end user just inputs a comma-separated list of ingredients, such as "chicken, egg, pasta" as well as the number of servings.

For this purpose, you may use the .

For sending files (other than images), you may only send PDF files They need to be before sending, and added as a message such as the below example.

Create a (manually from the OpenAI developer portal, or via API). This is the database holding the files you want the AI to use for its reasoning. You may want a separate vector store for different use cases (e.g. an "HR assistant" and an "Accountant assistant" operate best if they have their own vector stores)

Add (update or delete) the files you want to analyze using the .

Use the instead of chat completion. To enable file search, you must add the section tool_choice and tools to the input (read more in the documentation).

https://api.openai.com/v1/chat/completions
here
here
token
Chef
Chat Completion API
Vector Store
Vector store files API
Responses API
OpenAI API platform
here
Showroom
here
https://platform.openai.com
API Keys menu
Secret
Chat Completion API
converted to base64