Hello there, folks! Today, let’s dive into the fascinating world of automation using Airtable and OpenAI’s GPT-4. As my friend Jake would say, “Mastering automation is the pathway to achieving scalability.” Let’s not waste time and begin our tutorial on Chat GPT integration in your Airtable automation script.
Imagine having a script that can easily extract specific information from a job role’s webpage content without requiring any manual intervention. Sounds amazing, right? By integrating GPT-4 in your Airtable automation, you’ll make this imagination a reality.
Automation replaces the manual effort and GPT-4 integration gives it far much-needed intelligence.
Let’s take an example:
Consider you need to automate the process of extracting details such as description of the job, company name, location, contract type, recruiter’s email, phone, and more from a job webpage. Besides, you want to store these details in an Airtable base. Let’s explore a code block to achieve this:
// Get the page text content
var web_page_content = input.config().web_page_content;
// Creating the prompt for chat gpt
let message_content = "web page content:---\n" + web_page_content+"\n---\nExtract from the web page content the following field and give the result in a json format: \"job_description\", \"job position\", \"company_name\", \"location\", \"contract_type\", \"recruiter_email\", \"recruiter_phone\", \"remote_policy\", \"skills_and_tech\", \"required_residency\", \"required_experience\". For the description make a summary. Fill the values in english. Separate contract type by comma without space after the comma. If you are not sure about some field, let them empty."
// Creation of the request
var raw = JSON.stringify({
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": message_content
}
]
});
// Send the request
let response = await fetch("https://api.openai.com/v1/chat/completions",
{
method: 'POST',
body: raw,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-SecretToken'
}
}
);
// Parse the response
let jsonResponse = await response.json();
let jsonContent = jsonResponse.choices[0].message.content;
let content = JSON.parse(jsonContent);
// Then we store the data in our airtable table
output.set('description', content.job_description);
output.set('job_position', content.job_position);
output.set('company_name', content.company_name);
output.set('location', content.location);
output.set('contract_type', content.contract_type);
output.set('recruiter_email', content.recruiter_email);
output.set('recruiter_phone', content.recruiter_phone);
output.set('remote_policy', content.remote_policy);
output.set('skills_and_tech', content.skills_and_tech);
output.set('required_residency', content.required_residency;);
output.set('required_experience', content.required_experience);
First, the script receives the web page’s content. It sends a request to the Chat GPT-4 model with specific fields to extract. The model returns precise information in JSON format. And voila, the Airtable base is filled automatically with the parsed info!
Getting the API key
To leverage the full potential of OpenAI, you’ll need to obtain an API key. Visit the following link and generate a new key: OpenAI API Keys.
In conclusion, adding the power of OpenAI’s GPT-4 to our Airtable script raises our automation process to a whole new level. Remember Kofi, the coder who loves complexity? He might just love to add more complex integrations to this automation combo! Happy automating, my tech savvies!
Big shout out to OpenAI for providing access to the powerful GPT-4 model, and Airtable for the vector of automation.