Join us for a free workshop on Gravity Forms OpenAI
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.
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.
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).
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 45+ essential add-ons for Gravity Forms with support you can count on.
Hello,
I have what I hope is a quick and easy question. How are the Moderation feed and the Completions feeds supposed to work together? It seems like a Moderation feed should process first and then – if it doesn’t fail – trigger the Completions feed with the same content. I don’t really see how to do that. Is that how they are intended to work together?
Thanks!
Hi J,
They don’t currently work together. They are separate endpoints in OpenAI, so they can’t be processed together. Your best bet for this kind of workflow is to use two separate forms: one for moderation and one for completion. You could then use Easy Passthrough to pass the values from the first form to the second.
is there any video how to set merge tag for opeanai feed and check this ?
Hi Krishna,
We currently don’t have an official video for this, but we have an upcoming Workshop on 2nd March 2023 where we will address all these. In the meantime, I’ve sent you a link to a video with a similar use case on how to set it up via email. I hope it helps.
Best,
Is there a way to get 2 or more Open AI feeds to work on a single form submission? I have two response fields with each assigned to a feed. However, the second feed always generates a random response instead of capturing the information from the first feed.
Hi Umar,
I replied directly to you, but I’m posting my response here in case anyone else runs into the same issue.
The latest version of the plugin fixes the random response issue. The second feed does not populate “live” but will populate when the form submission is completed.
Hi there. This is so awesome. Thank you. I see the plugin now supports using custom/fine-tuned models. I know this is a big ask, but is there any chance please of providing a tutorial on how to do this? Thanks again. Richard.
That would be awesome. We’ve already followed up via email, Richard.
Best,
Hey Richard, not something we can do on the fly but we’ve been getting lots of similar requests around this plugin so we’re planning to dedicate our next workshop to all things GF + OpenAI.
Just be clear our actual next workshop is already scheduled so by next I mean the workshop after that one. 😄
I’m getting this error.
Fatal error: Uncaught Error: Call to undefined method WP_Error::is_old_school() in /home/customer/www/shayanahmedlatif.com/public_html/wp-content/plugins/gravityperks/gravityperks.php:494 Stack trace: #0 /home/customer/www/shayanahmedlatif.com/public_html/wp-content/plugins/gravityperks/gravityperks.php(573): GravityPerks::get_message(‘register_gravit…’, ‘gravityforms-op…’) #1 /home/customer/www/shayanahmedlatif.com/public_html/wp-includes/class-wp-hook.php(310): GravityPerks::after_perk_plugin_row(‘gravityforms-op…’, Array) #2 /home/customer/www/shayanahmedlatif.com/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #3 /home/customer/www/shayanahmedlatif.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/customer/www/shayanahmedlatif.com/public_html/wp-admin/includes/class-wp-plugins-list-table.php(1336): do_action(‘after_plugin_ro…’, ‘gravityforms-op…’, Array, ‘all’) #5 /home/customer/www/shayanahmedlatif.com/public_html/wp-admin/includes/class-wp-p in /home/customer/www/shayanahmedlatif.com/public_html/wp-content/plugins/gravityperks/gravityperks.php on line 494
I apologize for the trouble!
What version of Gravity Perks are you using?
I’m using a 2.6.9 version of gravity forms.
Thanks! It looks like you have an active license. I’ll follow-up with you via email.
Is there any way to display the API response in the body of any page or post after submission? i.e. not merging it into a form field.
I would prefer not to do this by passing the value in the querystring.
Hi Danny,
You can use the feed’s merge tag and display it in a confirmation. If you wish to display it on a page after submission, our Gravity Forms Post Content Merge Tags perk is a great fit.
Im advising to – add to map fields of PROMPT_TOKENS, COMPLETION_TOKENS,TOTAL_TOKENS used so we can exctract data from the returned response — i mean i make a field maybe (tokenused:3) which will capture amount of tokens and maybe charge users per tokens used
Hi there,
Thanks for the feature request! This is a good one.
We’ve added a new “raw” modifier in version 1.0-alpha-1.6 that you can use with the merge tag provided by the OpenAI feeds.
Example usage:
{:1:openai_feed_2,raw[usage/total_tokens]}
To get the value into a field, you can switch the merge tag to a Live Merge Tag and set it as the default value in a field. Live Merge Tags are provided by Gravity Forms Populate Anything.
Is it possible to show a progress bar/wheeel/please wait text, while waiting for gravitywiz to get an answer for my prompt from the openAI? Thank you
Do you mean on form submission or are you using Populate Anything’s Live Merge Tags?
I am using live merge tags. Without a visual feedback, the user might get confused. thanks
Hi Sara,
You can use the gppa_loading_target_meta javascript filter hook to display a spinner when live merge tag is populating a value. I hope this helps.
Best,
Thank you for pointing me to the right direction. unfortunately, the example at https://gravitywiz.com/documentation/gppa_loading_target_meta/#replace-live-merge-tags-individually-and-show-spinner does not explain exactly how i can show the spinner at a specific location (middle of the page). putting in the example code in the gravity perks javascript plugin does nothing to my form. a “real” JS example would be much appreciated.
Hi Sara,
The snippet adds the spinner in place of the Live Merge Tag value while it is loading. It only works inside HTML fields.
We do not currently have a solution for displaying the spinner in the middle of the page. If you are a Gravity Perks license holder, reach out to our support team and we’ll be happy to look into what it would take to add support for this.
How to integrate Dall-e? I don’t see a way to generate images.
Hi Joe,
This isn’t currently supported, but we are looking into adding it in a future update.
Something strange happened to my site when adding this. I was sending gravityform URL queries to another form and all of a sudden it wasnt sending checkboxes in the queries.
When I submitted my form (after manually adding in the correct checboxes) gravity view was not picking up on the checkboxes being ticked.
The only change I made to the site was installing openai. I deactivated it and it started working again.
Very strange.
Hello @David Smith,
I just bought Gravity Forms to use with OpenAI. It works great!
I have the same formatting problem as lewis rowlands but I can’t solve it with your answer. This is what I call the answer: https://prnt.sc/xn5GpygWcutT I get it as a string with no line break.
How to have the same formatting as in OpenAI (with line breaks)?
Thanks
Hi Vincent,
If David’s solution didn’t work for you, this will require some digging on your form setup. If you have an active Gravity Perks Advanced or Pro license, you can contact us via our support form.
Best,
Hello,
I’ve been looking for a form plugin to interact with Openai for quite some time and I think I’ve found it.
I want to ask a user to fill in some fields in a form that will be variables that I will use in an Openai prompt.
Ex : Field n°1 of my form = keyword Field n°2 of my form, ton of voice = fun OR serious, etc. Promtp to send at OpenAI = give me the definition of with this
After that, I want to display the results of the prompt, the answer of Openai, in the same page just after the form.
Do you think that is possible with gravity form and this plugin ?
Thanks for you help,
Hi Vincent,
Based on what you describe, this should be possible with our plugin!
Best,
It seems that the response back is not formatted. For example, when asking to create a recipe there are no line breaks so it comes back as one full paragraph.
Is there anyway to receive formatted text as it would be in openai playground?
Hey Lewis, if you map the value to a Paragraph field with the Rich Text Editor enabled, you’ll get full formatting preserved.
Hello Lewis, did you try David’s solution ? Bye, VL
How can you set this up to populate the output in to a another text field “after” you click submit? When I use Live Merge Tags, it’s sending the request and giving me the output back before I clicked submit … would be good if the form didn’t load a thank you submission or go to another confirmation page; just kept the form open so you can keep making requests.
Hey Sean, both “Edits” and “Completions” have the “Map Results to Field” setting. In this scenario, you wouldn’t use Live Merge Tags.
This sounds like the functionality Live Merge Tags offers you? Is the difference that you actually want to capture each input as an entry without actually submitted the form?
** Is the difference that you actually want to capture each input as an entry without actually submitted the form? **
Yes! Is that actually possible with Gravity Forms?
Not currently. Closest solution would be something like our Reload Form perk but the form would still be submitted, it just makes reloading the form very quick.
This could be even more useful if it allowed users to specify a fine-tuned or embedded model.
I agree! Our dev team is looking into what would be required to add support for this.
Agreed! We have plans to support fine-tuned models.
Curious, how do you see this working with embeddings? We’re still brainstorming on how to incorporate them.
Hi Danny,
Using fine-tuned models is now possible with version 1.0-alpha-1.4 of the plugin. Re-downloading the plugin should give you the latest version.
If you need a custom separator for your fine-tuned model, I recommend using the following snippet: https://gist.github.com/claygriffiths/1ae860d89d8349914a6b176912a2883e
Can I use this with a fine-tuned model?
Not yet! We plan on adding the ability to select fine-tuned models for completions soon.
Hi Amin,
Using fine-tuned models is now possible with version 1.0-alpha-1.4 of the plugin. Re-downloading the plugin should give you the latest version.
If you need a custom separator for your fine-tuned model, I recommend using the following snippet: https://gist.github.com/claygriffiths/1ae860d89d8349914a6b176912a2883e
I can’t for the life of me get this to work. I created a form with a single long paragraph for the user to paste a book blurb into, created a feed, used edits, added a prompt, chose to merge it to a results field, and then added that to a confirmations page. But all it does is give me the “thank you, we’ll be in touch shortly” which isn’t an option anywhere.
Does this require buying the live merge plugin too?
Hi Chelle,
It’s hard to say what might be happening without looking at your form configuration. If I had to guess, I would double-check the merge tag you’re using in the results field. If you’re a Gravity Perks customer, we’ll be happy to dig into this further. Drop us a line.
This plugin doesn’t require Populate Anything to function, but it does if you want to use Live Merge Tags to output the OpenAI response into a form field. Otherwise, you can use regular merge tags in confirmations and notifications.
so, i’m new to this chatgpt but have just seen how powerful it could be. can it for example, with this plugin, take a text or paraphrase field value from a live form and return a sentiment analysis on it , to another (hidden) field ?
i mean paragraph field !
HI Adnaan,
This works with Populate Anything, so you can use Live Merge tags to populate a Hidden field with the response. https://gravitywiz.com/gravity-forms-openai/comment-page-1/#populate-anything
Best,