PRO

OpenAI Integration

The WS Form OpenAI integration provides two key features:

  1. The ability dynamically create WordPress forms simply by entering a prompt describing the form you need.
  2. Integration with the core OpenAI endpoints into your WordPress forms for generating text and image content.

What is OpenAI?

Let’s ask OpenAI what it is…

Human: What is OpenAI?

AI: OpenAI is a nonprofit artificial intelligence research organization. It works on developing friendly AI systems to enhance human well-being, as well as create responsible, equitable AI solutions. OpenAI strives to operate transparently and collaboratively with the global AI research community. OpenAI’s main research areas are robotics, reinforcement learning, natural language processing, computer vision, and generative modeling.

Example Use Cases

Example use cases include:

  • Create a form by providing a description.
  • Produce text and image content when creating a post using the post management integration.
  • Provide the ability to improve copy in a text area field using instructions (e.g. Fix my grammar!).
  • Create an avatar image when using the user management integration.
  • Question and answer capability on a support page.
  • Moderate form submissions for inappropriate content.
  • Create text from an audio file containing speech.
  • Create spoken audio files from text.

Installation

The OpenAI plugin is free to purchase. Click here to download the integration.

The OpenAI plugin is installed in the same way as installing the WS Form PRO plugin.

Once installed you will need to activate the license for the plugin. When you purchase the OpenAI plugin, you will be given a license key. If you have lost your license key(s), click here.

To activate your license key:

  1. Click WS Form in the WordPress administration menu.
  2. Click Settings.
  3. Click the OpenAI tab at the top of the page.
  4. Enter your license key.
  5. Click the Activate button.

If your license key fails to activate, please ensure you are using the correct license key and not your WS Form PRO license key.

Create an OpenAI Account

  1. Visit the OpenAI homepage and click on Sign Up in the top right corner.
  2. Fill out the form with your information accept the terms and conditions and click Submit.
  3. Verify your email address by clicking on the link sent to your inbox.
  4. Log in to your new OpenAI account using the credentials you set up during the sign up process.
  5. Create an API key on the OpenAI API Keys page.

You are now ready to connect WS Form to OpenAI.

Connect WS Form to OpenAI

Connecting WS Form to OpenAI is easy!

  1. Click WS Form in the WordPress administration menu.
  2. Click Settings.
  3. Click the OpenAI tab at the top of the page.
  4. Enter your OpenAI API key. You can find this on the OpenAI API Keys page.
  5. Optionally enter your OpenAI organization ID.

There might be a short delay between setting your account up with OpenAI and your API key being ready for use.

Templates

The following templates are included with the OpenAI integration. To access these templates, click on Add New in the WS Form admin and then click the OpenAI tab.

The AI Generated Form template allows you to create a WordPress form simply by describing the type of form you want.

To create an AI generated form:

  1. Click WS Form in the WordPress administration menu.
  2. Click Add New.
  3. Click the OpenAI tab at the top of the page.
  4. Choose the AI Generated Form template.
  5. Enter a prompt that describes the form your require.
  6. Click Create to create the form.

An example prompt is as follows:

Create a support request form. Add instructions to the top of it and require the user to upload a screenshot. First name, last name, email and license key are required as well as a description of the issue. Include help text on each field to improve accessibility.

The following WS Form fields are currently supported when using this template:

  • Text
  • Text Area
  • Email
  • Phone
  • URL
  • Number
  • File Upload
  • Rating
  • Select
  • Checkbox
  • Radio
  • Number

Help text and placeholders can also be generated for each field. You can request these features in the description you provide to WS Form.

Once a form is created you can edit as you would any other form using the layout editor.

Creating a Form Integrated With OpenAI

Automatically

WS Form can create a form for an OpenAI endpoint in a single click. This process not only creates a form but also fully configures WS Form so that the form is ready to use immediately.

To create a OpenAI form in WS Form:

  1. Click WS Form in the WordPress administration menu.
  2. Click Add New.
WS Form PRO - OpenAI Integration - Add New Template
  1. Select the OpenAI tab at the top of the page.
  2. Click on an OpenAI template to create a form.
  3. Wait a few moments while the form is created.

That’s it! Your form will be created and is ready to add to your website.

Manually

It is also possible to use any form created in WS Form and add an action so that you can make OpenAI requests.

Add an OpenAI Action

  1. When editing your form, click the Actions  icon at the top of the page. The Actions sidebar will open on the right-hand side of the page.
  2. Click the Add  icon to add a new action.
  3. Select Make OpenAI Request from the Action pulldown.
  4. Click Save & Close.

You will noticed that the When Should This Action Run? setting has neither checkbox checked. This is because we recommend using conditional logic to run the OpenAI action when a custom button is clicked. This ensures the OpenAI requests run without submitting the form and keeps the user on the form while they interact with it.

Add Conditional Logic to Run the OpenAI Action

  1. Add a custom button to your form.
  2. Click the Conditional Logic  icon at the top of the layout editor.
  3. Create an IF condition that checks if the custom button has been clicked.
  4. Create a THEN statement and choose the Make OpenAI Request action, then choose Run Immediately.
  5. Click Save & Close.

The Make OpenAI Request action will now run when the custom button is clicked.

The OpenAI action settings depend on the endpoint selected.

Audio – Transcription

The OpenAI Audio endpoint is an advanced API designed for generating and manipulating audio content through AI algorithms.

The audio transcription action settings are as follows:

OpenAI Model

Choose the OpenAI model you want to use for this action.

An OpenAI Model is a pre-trained machine learning model that can be used for a variety of tasks such as natural language processing, image recognition, and more. OpenAI models can be used to build applications that are intelligent and able to learn from their data.

Learn more about OpenAI models.

Language

Choose the language of the speech in the audio file uploaded to the File Field.

File Field

Choose a file field on your form to use as the input.

Prompt Type

There are two ways of obtaining input for OpenAI:

  • Field
  • Mask
Prompt Field

If you choose the Field type, you simply choose a field on your form to use for the OpenAI input. You can choose any text based field such as a Text or Text Area field.

Mask

If you choose the Mask method you can create an input mask for OpenAI and use WS Form variables to dynamically insert field variables. See Input Mask below.

Prompt Field

Choose the field to use for the input (prompt). This will typically be a text area field on your form.

Prompt Mask

Use the input mask to create a custom prompt for OpenAI and use WS Form variables to dynamically insert field variables. This is particularly useful if you are developing prompt engineering for OpenAI. To learn more:

Response Format

Choose the response format of the converted speech.

Output Field

Choose the field to use for the output (speech to text). This will typically be a text area field on your form. The output field can also be configured as the same field as your input field. An example of this can be found in the Completion – Chat template where input and output are both contained within the same text area field.

Temperature

Choose the temperature setting for the OpenAI request.

The OpenAI Temperature setting is used to adjust how much of a random element is introduced into the output generated by the OpenAI model. A lower completion temperature indicates that the model should be more conservative in its output, while a higher temperature indicates that the model should be more creative with its output.

API Request Timeout (Seconds)

The maximum permissible time in seconds that the API request will run for. Longer timeouts may be required for longer or more complex OpenAI requests.

Variables

The OpenAI integration introduces the following variables for use in actions:

AI

VariableNameDescriptionUsage
#wp_ai_client_completion_tokensCompletion TokensReturns the completion token count.Actions
#wp_ai_client_inputInputReturns the input.Actions
#wp_ai_client_outputOutputReturns the output.Actions
#wp_ai_client_prompt_tokensPrompt TokensReturns the prompt token count.Actions
#wp_ai_client_total_tokensTotal TokensReturns the total token count.Actions
#wp_ai_client_typeTypeReturns the generation type.Actions

OpenAI

VariableNameDescriptionUsage
#openai_completion_tokensOutputReturns the completion token count from OpenAI.Actions
#openai_inputInputReturns the input for OpenAI.Actions
#openai_modeOutputReturns the OpenAI mode.Actions
#openai_outputOutputReturns the output from OpenAI.Actions
#openai_prompt_tokensPrompt TokensReturns the prompt token count from OpenAI.Actions
#openai_total_tokensOutputReturns the total token count from OpenAI.Actions