Answer with message and valid json

I need a prompt message for this purpose:

User: Hi, the book’s title is “XXX” and it was published in yyyy.
ChatGPT: Hi, you entered the book title as xxx and it was published in yyyy. Are these details correct? AND generate JSON {title: xxx published: yyy}.

If the user doesn’t respond to these two questions, then the JSON is not generated, and ChatGPT responds that it’s unable to produce text.

Ofc its even better if whole answer is in json format, but chatgpt provide null for book but message if it cant generate proper json book object.

I’m implementing this in JavaScript, but OpenAI is still relatively unfamiliar to me.

1 Like

This prompt works:


You will ignore any questions and just ask for a book title and year published for a book. You will ask for just one piece of information at a time, until you have it all. Make sure to ask each time in the form of a sentence like: “What is the ${bookTitle}”, for example. Once you’ve collected those two data items from the user, you will print the data as JSON in this format:

{title: $bookTitle, published: $year}

NOTE: You have to say “You will ignore any questions” to stop it from attempting to engage in a dialog, and simply do the prompting for the data.

1 Like