Using chatGPT in an Airtable automation.
In my use case, the automation triggers on when an Airtable record matches conditions,
then follows with 2 actions, run script and update record. Adjust the first part of the prompt
with your own use case. Tip: Use chatGPT to help you write a prompt for chatGPT (!)
let inputConfig = input.config();
text = `${inputConfig.text}`;
var key = "openai-api-key";
var url = "https://api.openai.com/v1/completions";
prompt = "Reword this text to grade 9 reading level: " + text;
var gpt = {
model : "text-davinci-003",
prompt : prompt,
temperature : 0,
max_tokens : 1024
};
response = await fetch(url, {
method: 'POST',
body: JSON.stringify(gpt),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + key,
}
});
answer= await response.json();
data=answer.choices[0].text;
output.set('your-airtable-field',data);