Integrating data from ChatGPT to a website/app via predefined prompts

Hello everyone,
I have a unique situation with my website and am wondering if the API option to ChatGPT would work with what I’m trying to accomplish (or if there’s another way). I have a website with the Bible on it. There are some other features on it as well, but for the purposes of this API I’m looking to connect ChatGPT to my website, and then based on a selected verse or verses in the Bible (that the user highlights) a predefined prompt would run. I would like to take the response from that predefined prompt and show it on my website. I don’t want the chatbot option on my website, but just the information from ChatGPT to show from that pre-defined prompt. I don’t mind if it shows up in a chat box and looks like that, but would prefer no interaction and just the data shown for the user. Is something like this possible to do?

Thank you,
Patrick

2 Likes

Hey Patrick,

Absolutely! You can totally do this with the OpenAI API. Here’s how it would work:

Instead of having a chatbot on your site, you’d just send the selected verse to the API using a predefined prompt and then display the response directly on the page. No need for users to interact like they would with a typical chatbot—just a static response.

Here’s the flow:

  1. User Interaction: When a user highlights a verse on your site, you capture that verse. Simple, right? You can do this with a bit of JavaScript.

  2. Predefined Prompt: Once they highlight the text, your backend (server) sends that verse to the OpenAI API along with a predefined prompt you’ve written. For example, you could send something like:
    “Provide a reflection on [insert highlighted verse].”

  3. ChatGPT’s Response: The API sends back a response based on the verse and your prompt. Now, instead of starting a conversation, you just take that response and display it on the page below the verse, like a commentary or reflection.

  4. No Chatbox Needed: It’s not a chatbot, but the response still comes from ChatGPT. You could show it in a clean, static box or text area on your website—whatever fits the design.

A Quick Example:

  • User highlights John 3:16.
  • The backend sends something like: “What is the meaning of John 3:16?” to the API.
  • Response: “John 3:16 emphasizes the importance of faith and God’s love for humanity…”
  • You just display that text right below the verse for the user, no interaction needed.

Latency Concerns:

Since this process requires sending a request to the API and waiting for the response, there might be a little delay. But as long as the API call is quick (and it generally is), the user won’t notice too much lag.

Let me know if you need help setting this up or refining the process!

Code example
// When user highlights a verse and clicks a button to submit:
const verse = “John 3:16”; // This would be captured dynamically from the website

// Example of sending verse to your backend
fetch(‘/api/getReflection’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
},
body: JSON.stringify({ verse })
}).then(response => response.json())
.then(data => {
// Display the ChatGPT response on your website
document.getElementById(‘response’).innerText = data.chatgptResponse;
});

Thanks so much for your response, Mitchell! So just to provide a little information, I’m working on a Bible app too which will have unique login for users. So with the flow that you provided, that should work as well so each individual user would be able to use the prompt to get that information for the Bible verse that they select?

Also, I would like to add additional prompts in the future and have just a button option to select and then have the information retrieved from ChatGPT based on the button (and prompt) selected. I’m assuming it would be possible to modify what you included above to be used for multiple prompts?

Patrick

Yes, the flow @mitchell_d00 provided should be suitable for that. The button idea should also work fine with a few minor modifications.

Might I also suggest caching (storing) responses—build up a set of responses of whatever size you deem necessary—and simply show one of those instead of using the model in real-time.

For more accurate responses you can use the assistant API, since it allows you to upload your website data along with a custom instruction. So the responses can be tailored rather than leaving it open ended.