Automate Customer Support with GPT Assistants and Airtable
Is this finally the time when your GPT assistant is able to know your company pricing and product features?
Customer support teams often find themselves answering the same questions repeatedly. With the latest OpenAI Assistants API, you can now leverage GPT-3 to automatically generate support responses based on your company’s internal knowledge. In this post, I’ll walk you through how to build a custom GPT assistant, connect it to your knowledge base, use it to create conversation threads, generate accurate replies, and integrate everything with Airtable and Gmail. Let’s get started!
Set Up Your GPT Assistant
First, we need to set up a custom GPT assistant within the OpenAI Platform playground. Here are the steps:
- Create a new assistant and give it a name.
- Provide general instruction for the assistant. Know we will be overriding those later.
- Select the
gpt-4-1106-preview
model since it's the best for assistants right now. - Enable the retrieval feature to connect your knowledge base.
- You may enable “Code Interpreter” if you expect some data analytical tasks
- Save the assistant and note down its ID (under the Name) — we’ll need this later.
Now we have an empty assistant ready to be configured.
Add Your Knowledge Base
Next, we need to add our knowledge base documents that the assistant can reference when generating replies. For this demo, I’m using an Airtable base with pre-populated FAQs grouped into categories like pricing, features, etc.
You can download the demo base from my Gumroad page.
To upload the FAQs into the OpenAI assistant knowledge store, I’m using a Make.com scenario with the following steps:
- Fetch all records from the Airtable FAQ table
- Aggregate the questions, types, and answers into a Markdown file
- Make an API call to OpenAI to upload the Markdown file and re-train the assistant on the new file
- Delete any old FAQ files and remove old file from the assistant
If you have not used Make.com it is an API integration and automation tool — similar to Zapier but more flexible and pleasant to use.
The key steps are handled by these Make modules:
- create a new Markdown file
- Upload assistant file to OpenAI
POST https://api.openai.com/v1/files
Header:
"Authorization: Bearer $OPENAI_API_KEY"
(Above authorization should be used in ALL API calls to open AI)
Body type "Multipart/form-data"
purpose="assistants"
file=@hereGoesTheRawFile
This translated to quite nice mapping in Make
- If old file exist - delete it from Open AI
DELETE https://api.openai.com/v1/files/{{file id here}}
- remove file association from old assistant
DELETE https://api.openai.com/v1/assistants/{{your assistant ID}}/files/{{file ID}}
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
#this header is needed for all assistants API
#operations, will likely change in the future
- Add new file to the assistant
POST https://api.openai.com/v1/assistants/{{assistant id}}/files
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
Body:
"Content-Type: application/json"
{
"file_id": "{{3.data.id}}"
}
Generate Reply Threads
With the knowledge base connected, we can start generating replies by:
- Creating a new thread when a form is submitted
- Adding the customer question as a message
- Running the thread through the assistant
- Repeatedly checking if processing is complete
- Retrieving the generated response
Here is what this looks like in the Make scenario:
Some key points:
- What triggers sending of the mails and generating replies is an automation that sends record ID to Make.com:
Read more below how to create script to send triggers from Airtable
- NEW! Create a new thread for each conversation. This is a new approach used by Assistants — different from completion API
POST https://api.openai.com/v1/threads
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
Make sure to enable parse response to get the details of the response object and ID of newly created thread
- We construct a detailed user message prompt with instructions for the assistant
- We need to add the user message to the thread
POST https://api.openai.com/v1/threads/{{thread ID}}/messages
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
Body:
"Content-Type: application/json"
{
"role": "user",
"content": {{23.json}}
}
- Run Assistant on your thread
POST https://api.openai.com/v1/threads/{{thread ID}}/runs
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
Body:
"Content-Type: application/json"
{
"assistant_id": "Assistant ID",
"instructions": {{34.json}}
}
- The response doesn’t come immediately — we need to poll until processing completes
GET https://api.openai.com/v1/threads/{{thread ID}}/runs/{{run ID}}
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
- We extract the text from the returned message
GET https://api.openai.com/v1/threads/{{thread ID}}/runs/{{run ID}}
Headers:
"Authorization: Bearer $OPENAI_API_KEY"
"OpenAI-Beta: assistants=v1"
The response of the Assistant will be on the top of the content array in the data object.
{{33.data.data[].content[].text.value}}
Now we can take form submissions, create threads, and get automated responses!
Connect Airtable and Gmail
The last step is connecting everything to Airtable forms and Gmail.
When the “Send Email” button is clicked, record ID is passed via the trigger to the scenario that constructs a reply email using Gmail and sends it to the customer.
Final step is connecting Gmail. Note that we use Markdown component to convert Airtable markdown (rich field text) to HTML that can be accepted by Gmail
Now when a customer fills out the form, everything is handled automatically — from getting the generated response to sending a personalized email reply!
Conclusion
With the new GPT assistant API, you can easily create AI-powered customer support bots personalized to your business knowledge. Connecting it to Airtable and Gmail transforms the entire customer inquiry process — from submission to response.
Let me know if you have any other ideas for automating customer support with GPT! I’m excited to see all the new use cases as the assistant API matures.
Get the Airtable base starter and ready made blueprints here.
Watch the full walk through tutorial here:
Useful readings:
- Open AI API docs — https://platform.openai.com/docs/api-reference/assistants
- Assistants API documentation — https://platform.openai.com/docs/assistants/how-it-works
Visit our Gumroad store for a ready made blueprints and as always do not forget to checkout our Youtube Channel for all things related to automating your business!
Business Automated is an independent automation consultancy. If you would like to request custom automation for your business, visit us at https://www.business-automated.com
If you like our tutorials — buy us a coffee☕: https://www.buymeacoffee.com/business
Follow us on Twitter🐦: https://twitter.com/BAutomated
Watch more on YouTube ️📺: https://www.youtube.com/c/BusinessAutomatedTutorials