Overview
Gravity Forms OpenAI is a free plugin that integrates Gravity Forms with OpenAI – the leading provider of cutting-edge AI language models.
This plugin allows you to send prompts constructed from your form data to OpenAI and capture its responses alongside the submission. You can also utilize the power of AI to edit submitted data for grammar, spelling, word substitutions, and even full rewrites for readability or tone. Lastly, GF OpenAI allows you to moderate submissions and flag, block, or spam undesirable content.
Getting Started
Install plugin
Get an OpenAI API key
Assuming you’re already using Gravity Forms, there’s only one thing you’ll need to get started with GF OpenAI: an OpenAI API key!
We’ll let ChatGPT (powered by OpenAI) explain how to get your own. 😉
Here’s a shortcut if you already have an OpenAI account.
Once you have your API key, copy it and paste it into the GF OpenAI plugin settings by navigating to Forms › Settings › OpenAI.
Workshop Crash Course
Before we dig into the instructions for using this plugin, you may find our crash course workshop to be a useful starting point. Take a look as we explore some popular use cases, fine-tune models, explore how a marketing agency can use OpenAI with Gravity Forms, and answer questions from the audience!
Don't miss a thing. Get our weekly updates by owl or email. Ok, we're still working on the owl service, so just email for now.
Using the Plugin
Our plugin works with Gravity Forms in a few different ways to make it easy to use OpenAI’s powerful AI capabilities with your forms.
Chat Completions
Chat Completions is OpenAI’s newest endpoint, while also the cheapest and fastest by far. It’s also the most robust model, able to handle and respond accurately with to largest variety of prompt types. In fact, it’s the same model that powers ChatGPT.
Some great use cases for Chat Completions include: debugging code, generating documentation, and answering user questions!
Chat Completion Options
OpenAI Model – Chat completions uses the gpt-3.5-turbo
model. gpt-4
is also supported, but gpt-3.5-turbo
is the fastest and most cost-effective option from OpenAI.
Prompt – Any combination of form data (represented as merge tags) and static text that will be sent to the selected OpenAI model and to which the model will respond.
Merge Tag – Enable merge tags to output the result of an OpenAI feed in form confirmations, notifications, or even live in your form fields (via Populate Anything’s Live Merge Tags).
Map Results to Field – All OpenAI responses will be captured as an entry note. Use this setting to optionally map the response to a form field.
Completions
Completions provide an easy way to interact with OpenAI’s versatile language models. Send any combination of form data as a prompt and whatever model you’ve selected will generate a text completion with its best attempt to match the intent of your prompt.
For example, if you give the API the prompt, “Write a slogan for Gravity Forms”, it will return a completion like “Effortlessly capture and manage your data with Gravity Forms.”
Completion Options
OpenAI Model – Select the model that is the best fit for your needs. OpenAI offers a variety of models, each with its own strengths and capabilities. This plugin supports gpt-3.5-turbo
and gpt-4
, among others. The key differentiators between each model will be speed, quality, and cost.
Prompt – Any combination of form data (represented as merge tags) and static text that will be sent to the selected OpenAI model and to which the model will respond.
Merge Tag – Enable merge tags to output the result of an OpenAI feed in form confirmations, notifications, or even live in your form fields (via Populate Anything’s Live Merge Tags).
Map Results to Field – All OpenAI responses will be captured as an entry note. Use this setting to optionally map the response to a form field.
Edits
Edits makes it easy to generate and capture suggestions for texts edits to submitted form data. Provide a prompt and an instruction for how that prompt should be edited and OpenAI will return an edited version of the prompt.
This can be useful for a variety of purposes, such as improving the grammar and clarity of user-generated content, or providing automated copyediting services.
OpenAI Model – Select the model that is the best fit for your needs. OpenAI offers two models here – one focused on editing text and the other on code.
Input – Any combination of form data (represented as merge tags) and static text that will be sent to the selected OpenAI model and to which the model will apply the Instruction.
Instruction – Explain to the model how you would like the input edited. Example: “Fix spelling mistakes and format as a sentence.”
Merge Tag – Enable merge tags to output the result of an OpenAI feed in form confirmations, notifications, or even live in your form fields (via Populate Anything’s Live Merge Tags).
Map Results to Field – All OpenAI responses will be captured as an entry note. Use this setting to optionally map the response to a form field.
Moderations
Moderations allow you to check if submitted data complies with OpenAI’s content policy. This will flag inappropriate or harmful content and our plugin will let you decide what to do with that submission. You can block the submission, returning a validation error, mark the entry as spam, or record OpenAI’s response but do nothing.
OpenAI Model – Select the model that is the best fit for your needs. If you want the latest AI technology, use test-moderation-latest
. Otherwise, stick with text-moderation-stable
.
Input – Any combination of form data (represented as merge tags) and static text that will be sent to the selected OpenAI model for evaluation.
Behavior – Decide what to do if the submitted input fails validation. You can:
- Prevent submission by showing validation error
The submission will be blocked and a validation error will be displayed. Due to the nature of how data is sent to OpenAI, specific fields cannot be highlighted as having failed validation. - Mark entry as spam
The submission will be allowed by the entry will be marked as spam. Gravity Forms does not process notifications or feeds for spammed entries. - Do nothing
The submission will be allowed and the failed validation will be logged as a note on the entry.
Live Results with Live Merge Tags
If you’d like to show live results from OpenAI directly in your form, Populate Anything’s Live Merge Tags (LMTs) makes this possible. LMTs provide the ability to automatically replace a merge tag with live content as soon as its associated field is updated. LMTs work anywhere inside your form (field values, labels, HTML content) and can be used to process GF OpenAI feeds.
You can get the “live” version of your GF OpenAI feed merge tag by enabling the Enable Merge Tag setting on your GF OpenAI feed and copying the desired merge tag.
@{:1:openai_feed_2}
→ Will process the specified feed anytime the value in field ID 1 is changed. Update the “1” to any field that you would like to trigger the Live Merge Tag.
@{all_fields:openai_feed_2}
→ This LMT will be processed when any field value changes. This is useful if your prompt contains more than one field value.
Trigger Live Results by Button Click
When you use Live Merge Tags with an OpenAI feed, by default, the feed processes as soon as the merge tag value changes. This may not be ideal if the user is still entering data.
Thankfully, there’s a snippet that solves this problem. This snippet changes the default behavior to only trigger the feed when a button is clicked instead of when the input field is changed.
Merge Tag Modifiers
Include Line Breaks in Text
If you’re looking to include line breaks when using an OpenAI merge tag with an HTML field, you can include the :nl2br
modifier in your merge tag code. Here’s an example of what the output looks like with and without the modifier:
Without the modifier, all results are on one line:
@{:1:openai_feed_2}
1. Mars 2. Venus 3. Pluto
With the modifier added, each result gets separated on its own line:
@{:1:openai_feed_2,nl2br}
1. Mars
2. Venus
3. Pluto
Integrations
Populate Anything
With the power of Live Merge Tags, you can process OpenAI feeds as your users type and display the response live in an HTML field or capture it in any text-based field type (i.e. Single Line Text, Paragraph, etc).
Gravity Flow
GF OpenAI is fully integrated with Gravity Flow. While you’re building your workflow, choose Open AI as the step type and select the OpenAI feed you’d like to use:
Here’s a quick example of what a workflow in Gravity Flow could look like:
- A user submits a form designed to create an outline for their article.
- GF OpenAI handles the outline.
- A Gravity Flow approval step requires an editor to approve the outline.
- After approval, a rough article draft is generated based on that outline via GF OpenAI.
- A Notification step brings users back to review the generated article, make edits, and submit a final version.
- Post Creation generates an article and publishes it.
FAQs
How much does this cost?
Gravity Forms OpenAI (this plugin) is free! OpenAI (the service this plugin integrates with) also gives you $18 in free credit when you signup. After that, OpenAI is still remarkably inexpensive. As of Dec 15th, 2022, you’ll pay about $0.02 per 1000 tokens (~750 words) generated by OpenAI. Full pricing details here.
I need some inspiration… what can I do with OpenAI?
OpenAI has an amazing list of examples here. If that doesn’t whet your whistle, try asking ChatGPT itself. You’ll be surprised with how clever it can be. 😉
I want to contribute to this plugin!
If you’re looking to contribute to the codebase, PRs are welcome! Come work with us on Github. If you want to contribute financially, pick up a Gravity Perks license. It’s a win-win. 😄
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 46+ essential add-ons for Gravity Forms with support you can count on.
Following up on Ali’s question about Azure, we have a use case that needs GPT for our private data, not for the general ChatGPT.
The Azure team seem to support that as per this link: https://techcommunity.microsoft.com/t5/ai-applied-ai-blog/revolutionize-your-enterprise-data-with-chatgpt-next-gen-apps-w/ba-p/3762087
It would be really great if we could be a Gravity Forms OpenAI customer and be able to link to an Azure-hosted dataset and have a similar usage based pricing model with Gravity WIZ.
Do you think this is possible in the near future? Would much rather wait than to chase off on a major one-off development project.
Thanks!
Marty
Hi Marty,
This is currently not in our plans in the near future. I will still forward this as a feature request. Hopefully, with more similar requests, this may be a priority.
Best,
Hello!
Any chance we can use Azure? Having some issues with Openai but have azure api access.
Hi Ali,
This is currently not possible. I will forward your request to our Product manager as a feature request.
Best,
thank you! I’ve also heard that because of extreme load on chat gpt, azure might offer better speeds.
Does anyone have an example of executing this from a button click? I can’t seem to get the code to work.
Hi Conor,
I’m not sure I’m tracking this question. When the submit button is clicked, the OpenAI feed processes and the results are stored in the field that has been mapped in the feed settings.
If you’re having trouble using the plugin and are a Gravity Perks subscriber, reach out to support. We’re happy to help.
Hi,
Any updates on the GPT 4 support in the plugin? Saw that you are working on it beneath my last question.
Hi Harry,
Support for GPT 4 has been added to the Open AI plugin. Download the plugin again to get the latest version. It requires your account have GPT-4 enabled.
Best,