If you’ve been tinkering with the OpenAI Zapier integration, you may have come across the ‘Search embeddings’ action. This article covers the fundamentals of what embeddings are in AI and explains how to set up an OpenAI Search Embedding step in your Zap.
In simple terms, embedding in AI compares how similar two (or more) pieces of data are to each other. For example, the word “dog” and “wolf” would both be closely related to the word “canine”, but if the embedding we use is “pet” then dog will be a much closer match.
Embedding is commonly used in apps to do things like compare your search question to useful answers or show you products that might be relevant to other things you’ve looked at. If you want to learn more about the theory behind embeddings, I found this video really helpful:
Using Embeddings with OpenAI in Zapier
In Zapier, you can add text as the input of an embedding step and ask the action to compare that a list of categories. The input of the action is called the ‘Query’, and the list of categories are called ‘Documents’.
The output of a search embeddings step is a ranked list of how close a match the query is to the different documents (categories). When you test the Search Embeddings action, the action gives you the best match and a list of the other matches ranked by closeness:
For example, using the query above, you get:
You’ll notice that cat ranks as a closer match for ‘large animal’ than wolf does. This highlights a limitation of using embeddings. The action looks at the text and ranks the matches according to how associated the words are. In this case ‘large animal’ and ‘cat’ might be more closely related because we often refer to lions and tigers as ‘big cats’. If you use the Search Embeddings action in your Zap, take some time to test your documents against different queries to make sure that you’re reliably finding the best match.
A Search Embeddings use case
Let’s look at an example of how you could use the Search Embeddings step in your Zap. I’ll describe what the Zap does and explain how to set it up.
Imagine that you’re a small business owner, and customers email you about their orders. If a customer isn’t happy with the product or service, you need to know right away so you can put it right. You can use the Search Embeddings action to alert you immediately if you have an unhappy customer.Here’s the outline of the Zap:
The magic happens in the OpenAI step. Here’s how you need to set it up:
- In the Query field, add the body of the email
- Add the different categories in the Documents field, one category on each
The filter step only allows the Zap to continue if the Best Match Value from the OpenAI step is ‘Angry’
💡 To make the Search Embeddings action more robust, use categories that are different from each other, and only use as many categories as you need.
Finally, if the message is deemed to be ‘Angry’ and passes the Filter, the Zap will send you a text message using SMS by Zapier. You can customize this message and I set it up so that the text message includes the name of the customer and a link to their email.
Put all that together and whenever I get an email from an unhappy customer, I get a text message and can go straight to the email to take action.
I hope you enjoyed this introduction to using the Search Embeddings action for OpenAI. We covered what embeddings are and how to set up a Search Embeddings step. In this article, ee looked at using fixed values for the documents, where you type something into the fields. The next stage of using this action would be to dynamically add them from a previous step in your Zap. If you’d like to know more about that let us know if you’d like to see an article that dives into that!