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.
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. This model 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. The key differentiators between each model will be its 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.
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.
Is there a way to persist a chat in Turbo? ex: I have a workflow that has an initial prompt that is fairly detailed, then use the results of that to generate several others. Rather than sending the results as part of each subsequent prompt, I’d like to just add additional queries.
Sounds like you’re looking for something more ChatCPT-like? If so, we don’t currently have a solution for that but it’s on our radar.
Something like that yes. Using a fairly complex prompt as a setup, then generating several different types of content based on the results of the first prompt. Asking for it all at once is more tokens than allowed.
I use live merge tags in my gravity forms to populate some text fields with openai. Unfortunately, when click the submit button of my form, all the text fields with a live openai merge tag, are submitted to openai for the second time (making me billed twice). is there a workaround to prevent this from happening? Thank you for your amazing plugin and free support.
Hi Sara,
This sounds like a configuration issue. Do note that while the plugin is free, support is not. We’re happy to answer questions here, but help with specific configurations requires a Gravity Perks license.
If you have one already, we’ll be happy to help if you contact us via the support form.
Hi , i am using the plugin with Completions. With the {openai_feed_1} i am getting my answer back and works fine when i check it in Notes ! BUT i created also 2 notifications and when i add the {all_fields:openai_feed_1} in the Notifications, Then the email arrives with a Different answer than the 1 in Notes. In Notes is better !
Why is that? Does it call more than 1 time the API when i am having Notifications with the {all_fields:openai_feed_1} too ?
Thank you in advance
Hi Antonis, when testing locally, it seems to work as expected. I get always the same output. This will probably require some digging on your setup. If you have an Advanced or Pro license, you can reach out via our support form, and we should be able to help.
Hello, a multiline result save in a text field. Unfortunately, this is then output as a single line in notifications. Is there a solution for this?
Hi Oliver, we’ve already followed up via email to help you here.
Upcoming version introduces the :nl2br modifier for better control over when new lines are honored or ignored.
Hi, any plans to integrate the new model: gpt-3.5-turbo
Thanks
Best, Oliver
Hi Oliver,
Support was added in the latest release 1.0-beta-1. You can download it using the Download Plugin button above.
You must select the new Chat Completions endpoint for the model to be available.
Lifesaving plugin! To me, with livemergetags, if I exceed openai token limits, no error messages are displayed to the end user (and of course, no text is generated). is there a hook in your openAI plugin or gravity forms or live merge tags, that I can connect to so I can write custom code to send my long text in chunks to OpenAI and then return all the processed chunks in one piece to the user? If this is insane, any other alternatives (such as embeddings) that can be somehow used with your extension? Thank you
Hi Sara, I’ll ping our product manager for an investigation about this feature.
Cool idea but no solution for this just yet.
Unless there is a better way, I got embeddings to work by hooking into the gf_openai_request_body plugin filter of this plugin, gathering the prompt text, using curl to get the prompt’s embedding vector from OpenAI, sending it to the vector db, getting results back and formatting it as appropriate, then edit in that plugin filter the formatted results so that what it sends to OpenAI is your embedding results + your prompt.
Thanks for the feedback Alex!
Can we connect this to the GPT3.5 turbo API that came out this week? or DALL-E2 for images?
Do you have plans to implement the new ChatGPT API to the plugin? Currently using text-davinci-003, but I think that gpt-3.5-turbo can help me create a better crafted output.
Heck yeah, Freddy. It’s available in the latest version above. 😉
Do you have more in depth documentation on how to use this plugin? I’m pretty lost… haha I know what I’m trying to build, but got very lost trying to get there ;-}
Hi Michael, if you have an Advanced or Pro license, you can reach out via our support form and we should be able to help. We will have a Workshop on March 2nd about Open AI that you can join too.
Best,
Is there anyway to do conditional logic inside the actual prompt? Does the gravityforms notification/confirmation shortcodes work?
Hi Lewis,
There isn’t, but we’d love to hear more about your use case. Can you reach out to us via our support form? We’ll see if we can come up with a solution for you.
will do,
with regards to the fine-tuned model that you have added support for how exactly do we get that to work I cant see any documentation. Thanks :-)
Hi Lewis,
You’ll need to train the fine-tuned model. Once you have a trained model in your account, it will show up as an available model in the feed settings.