Add Embeds to your Flow
Last updated
Last updated
Now that you understand what embeds are and more importantly how to structure them for the best possible responses. Let's go ahead and add the embeddings to a basic flow design.
OK, first let's open a flow for testing or if you have a live flow you can follow the same steps.
Open up an Action node > select integrations > Select OpenAI
Once you have selected the OpenAI tab, a new window will display, scroll down a little bit and you'll see 2 Embedding actions you can use.
Embedding Match
Embedding Match and Completion
Open up the Embedding Match action and you'll see the editing window below.
Let's break it down -
Input: Within the input tab you can insert many text variables, most common will be the users question field. for example using the last text input field {{last_text_input}}.
Types: Types are no longer support by OpenAI.
Minimum score: This is a confidence score that the response will give if/when the AI find the embedding you have created. The range is from 0 to 1. The higher the number the better AI will match if you have an embedding. We find a score of 0.34 to work in most cases.
With the basics out of the way, let's test the embedding match by asking a question. To ask a question first add a custom field value to the input box. We have used the {{last_text_input}} field for this example. Once you have added a custom field, a new box will display to the right. Type your question here 'Shown below' "Do you have a free trial"
Once inputted click the Test Request Button.
Below you will see the response data the AI has sent back.
Great, now that you have a response back we can now use this information to do many things. First let's breakdown the full response so you understand exactly what it is.
The heading data displays the Heading title you created in the embedding it's self. But, it's more than just a heading! You can use this value to move your users around different parts or your chatbot workflows, which we'll cover in the error handling module.
Once you have selected the 'heading' line, denoted by the blue highlighted circle, you can now save the data into a text custom field over to the right hand side: 'Map response to custom field'. once done, click and save.
Next up is the Text. The text line displays all of the information you added to the embedding itself. It's optional if you want to save the information into a text custom field, just like we done above with the heading data. Just repeat the process if you need it.
The score is generated by the AI - The score denotes how strong the match is. Basically if it exists or not and how good the AI could match the users question to the embedding. The value of the score ranges. If its low 0.01 for example, the match result is low, the higher the score the better the match. We find around the 0.34 is the sweet spot. But as always, do go ahead and test your self.
Again, be sure to save it on the right side in to a custom field, this time it will be a number field. We can use this later on too.
The main difference between the embed match, and the embed match and completion is that the the completion action will display the answer from the AI, which will be sent to your user. Ok, let's take a look at the embedding Match and Completion action:
Let's quickly break it down.
Input: The input will be the users question, again in this example we're using the {{last_text_input}} custom field.
Introduction: The introduction is just like a prompt, so if you want to add an additional prompt or instruction here then you can 'optional'
Max tokens: You can change the amount of tokens for the response, 100 - 200 works fine. But as always 'test'.
OK, next add a question so we can test the response. My question is "Do you have a free trial?"
Once done, click the Test Request button.
Great it worked! OK, so there are 2 points of interest here.
Heading
Completion
Just like the embed match heading, the embed match and completion also has a heading - go ahead and save that to a custom field too.
The most important part is the Completion. The completion is the AI response. and as always save it to a custom field.
Below is an example flow with the embeddings actions added. Either side of those we added a question node, one that asks a question the other displays the AI response. The last one that displays the ai response, loops back to the embedding match node. This way if the user asks another question it will reply again and again. In the Combine embed with functions module, you'll learn some smart ways to use embeddings... See you there.