Create a Multifunction Customer Service Agent with Flow XO and ChatGPT

ChatGPT has been taking the world by storm, and for good reason. ChatGPT, and other AI of its kind, known as Large Language Models (or LLMs), is probably the most significant technology advancement of the last decade, and we are just beginning to understand how it will change our businesses and our world in general. One of the many promising applications of this technology, which gives computers the ability to understand, reason about and generate language, is in the domain of chatbots and conversational agents.

One of the best things about ChatGPT is how flexible it is. Although the interface is quite simple - you provide a simple text prompt, and ChatGPT provides a text response - it can be used for many different previously difficult tasks that are important for high quality chatbots:

  • Intent Detection - understanding and categorizing a users input into a fixed set of "intents" that a computer can understand and respond to
  • Question Answering - given a set of reference data, or context, answering a users questions about that information
  • Entity Detection - picking out important data points present in a users input and extracting those data points into arguments that can be used for API calls and other logic
  • Language Detection & Translation - determining the language of an input and translating text to and from various languages

In this article we will use Flow XO in combination with ChatGPT from OpenAI to build a multi-purpose customer service agent for the fictional company SuperCo, which sells AI teddy bears. In this article we will demonstrate using Intent Detection, Question Answering and Entity Detection. In another article we will cover Translation use cases.

Before we get started, you will want to make sure you can connect to ChatGPT from Flow XO. Please see this article to get connected: https://support.flowxo.com/article/296-open-ai.

Just need AI powered Q&A on top of your own business data or helpdesk content?

See our Knowledge Base feature, which makes giving your chatbot infinite cosmic knowledge about your business instant and easy.
Need to have complete control of your ChatGPT prompts, but would like to incorporate dynamic, relevant content from your own business data? Here you go.

A quick note on Open AI reliability and performance

Due to its massive and sudden popularity, the Open AI API can be somewhat unpredictable in terms of response times. Most requests may complete in 2-10 seconds, which is fast enough for interacting with a user in a chatbot scenario, but often enough a ChatGPT API request will take 30 seconds or longer, which is too long for a user to wait without thinking your bot is broken. See this article for some ideas on how to keep your user up to date on what is going on:   working with subflows

The conversational agent we will build will have the following structure:

  1. Dispatcher:  receives user question or command, determines if the question or command can be handled by our bot, and then either providing a response (possibly executing a command in the process), transferring the user to a live agent, or letting the user know we can't handle their query and asking them to rephrase.
  2. System Status Intent Handler: Answers the users query related to the status of the companies software
  3. Q & A Intent Handler: Answers users general questions about the company
  4. User Search Command Handler: Performs a user search in response to a command

Here is what the logical flow of the agent looks like:

Here's a brief example conversation with our agent:

To accomplish these tasks, we will mainly be using two tasks from the Flow XO OpenAI integration:

  • Detect User Intent - this task makes it easy to convert free text input from a user into an "intent" or category that we can use to direct the flow of the conversation. Although we won't be using it in this demo, this task can also detect the language the user is writing in.
  • Complete Chat - this task is the swiss army knife of ChatGPT - we will be using it to answer questions based on reference data, or "context", and we will also use it to extract command arguments for the user search.

Building the Agent

Make sure you have signed up for Flow XO and OpenAI, and connected the two. Pay attention to the "Reliability settings" when you create your connection with Flow XO as these settings can impact if the integration connects successfully.

I'm not going to go over the basics of creating flows in this tutorial - this article is meant to cover how to use ChatGPT to build an agent, and for simplicity I'm assuming you already know a little bit about how to use Flow XO. If you need to get up to speed, please see the following resources:

Introduction to Flow XO, Building Flows or take a look at our super simple starter flow. Need to trigger one flow from another? Read this. For a quickstart on working with ChatGPT and Open AI to build AI driven flows, see here and here.

If you want to follow along, you can import the completed flows into your account now:

  1.  Dispatcher Flow: https://flowxo.com/share/intelligence-artificial-4243
  2. Intent Handler - Information Request: https://flowxo.com/share/collaborative-self-6527
  3. Intent Handler - System Status: https://flowxo.com/share/upward-mobile-8831
  4. Intent Handler - User Search: https://flowxo.com/share/banshees-moratorium-3492
  5. Error handler: https://flowxo.com/share/wireless-country-2932

First, we'll work on the "Dispatcher" component. This flow will accept any incoming messages from the user, detect the users intention, then either provide a response or delegate to another more specific flow to handle the request. For that reason, we'll use a "Catch All" trigger. Here is what the completed flow looks like. We'll go through each step one by one.

  1. Catch All Trigger
    This is super simple. This trigger simply responds to every message from the user, if no other flow with a more specific trigger handles the message. For our agent, this will capture ALL user messages as we don't have any other flows that handle incoming messages.
  2. Greet User
    This is a "Send a Message" step that greets new users and gives them some hints on how to use the bot. The important part of this step is the filter - we ONLY want this message to be sent the first time the user interacts with the bot. When a new user connects to your bot, a special message with "start" or "/start" is sent, and so in our filter for this step, we'll check for those messages.

    Note that the condition is "Equals one of" and the value are the two messages we want to match (start and /start) separated by a comma. The arrow is pointing to a very important aspect of action filters that we'll use a lot in this tutorial - "Also stop rest of flow if conditions are met". This means that when the step is executed, the flow stops, skipping any additional actions. We are doing that here because the user hasn't typed anything in yet - there is no user message for us to process with the AI - we just want to let the user know the bot is ready for them, and then stop and wait for a new message from the user.
  3. Get Chat Transcript
    Once we make it to this step, we have an incoming message from the user. We are going to fetch a small portion of the chat history to pass to our intent detector. In some cases, this helps the intent detection step understand what the user is asking even if the message doesn't have the whole context. In the example conversation above, note that after getting an update on system status, the user asked "when will it be fixed?". The user did not specify what "it" is - but because of the chat history, the bot can understand that "it" refers to the app itself. Note in the screenshot that we are including a very small number of previous messages - for intent detection specifically (unlike the more general purpose Complete Chat steps), we are really only concerned with the most recent message from the agent and the user.
  4. Detect User Intent
    This is the heart of this flow. We use a "Detect User Intent" step from the Open AI integration to determine what the user wants, so we can respond accordingly. It is important to note that "Detect user intent" is not a function provided by the ChatGPT API - it's really just a "prompt template". We have constructed a few "template" steps to make common tasks easier, such as intent detection, translation, and summarization. But under the hood, we're just constructing a prompt on your behalf and submitting it to the raw ChatGPT API. This means that if the intent detector isn't working the way you like, you can just make your own using the "Complete Chat" or "Complete Text" actions. This is described in detail here: https://support.flowxo.com/article/297-bringing-your-chatbots-to-life-with-flow-xo-and-chatgpt


    This is the most important step in our agent, so we're going to spend some time going each part of it.

    Input Text - here we just pass in the raw message from the user

    Intents - this is the key configuration of this step. This is where we define all the intents our agent is designed to handle. You can put anything you want as intent names, but the names you choose are very important, because ChatGPT will try to match the users text to the name of the intent based on its understanding of the name of the intent. Jumping down to the "examples" section you can see we provided *some* examples to help ChatGPT choose the correct intent, but we did not provide an example for each of our intents. That is because you only have to provide examples to correct errors ChatGPT is making automatically guessing the best intent for the users message. It does a pretty good job usually of matching the users message to your intents if you name your intents well. In our example, we are using GPT-3.5 Turbo (ChatGPT), but if you have been granted access to GPT-4 you can use that as a model as well. It does a much better job with less examples, but it is slower and more expensive, and currently not available to all users.

    In any case, you want to provide your intents with each intent separated by a comma. You do NOT need to include "unknown" as an intent, because we add that for you. But it is important to understand that if ChatGPT doesn't match the user input to one of your intents, it will choose "unknown", so you will need to handle this.

    It is also important that you handle EVER intent that you specify in the list inside your flow. Otherwise, your bot will just not answer your user, which is not something you want to happen.

    Examples - In the examples, you can provide some hints to ChatGPT to help it correctly classify user messages into your intents. You really only need to provide examples where your testing ChatGPT is making mistakes, but you can also provide a few examples for every single one of your intents if you like. This might require you to do less trial and error your testing. But picking the right examples is a bit of a black magic art - ChatGPT is a statistical model that is far too complicated to be able to have a set of fixed rules for how the examples will influence the intent detection. So you will definitely need to do a lot of testing. That is the beauty and the drawback of these AI models, is that they seem like they can magically understand nearly anything, BUT, on the other hand, they can be very difficult to control. Like a wild horse, you have to break them sometimes, and you still never know with complete certainty what they will do. For example, from time to time, instead of responding with an intent from the list, ChatGPT will respond with a random full text response. Or, it might sometimes make up an intent that is not in the list. When this happens, our "Detect User Intent" task will detect that and return the "unknown" intent.

    Note as well that we are including a language code in our samples. This highlights another bit of ChatGPT magic. It can understand many common languages. So when you create your examples, if you are using something other than english, you should include the language code. This will help it correctly identify the languages your user is using. You do NOT need to include a code for every language you want to detect, just make sure that if you put in an example in something other than English to include the language code. Check this out:


    In that conversation, we asked "What is your most popular product" in Russian. The AI correctly identified the intent "general_info_request", found the answer in our reference data provided only in English, and then responded in Russian. We did not provide ANY configuration or hints at all to tell the system about Russian - we built this agent entirely in English. Even so, ChatGPT works best in English, because that is the bulk of its training data, and it works best when it's configured in the same language as your users. So examples like the one above might just work like magic, as they did in this case, or, they might have unexpected results, and require more tweaking based on your user testing. But it's pretty amazing stuff, and GPT-4 is even better at this, if you don't mind the speed and cost.

    Message History  - here we just insert the chat transcript we loaded in the step before. This can, in some cases, help the intent detector be aware of the context when the user types a message that does not include enough context, like "when will it be fixed". However the intent detector is not nearly as good at using context as the raw "Complete Chat" API for a variety of reasons, so plenty of testing and possible tweaking of examples may be required to make the intent detector do what you want in situations where the user is referring to the previous part of the conversation.

    Agent Description - Here we are simply providing the name and function of our assistant. By default, we call it "An AI intent detection service". This configuration really only influences how the "Suggested Response" is generated, which we don't use except in the case of the "smalltalk" intent, but it can be helpful if you don't want a separate step to respond to smalltalk and you want the assistant to refer to itself by name. However, this might also influence the performance of the intent detection, so one thing to try if you aren't getting the results you want is to leave this field empty or the default value. Again, we're dealing with a touch of black magic here, so test, test test!

    Unknown Intent - This is where you can rename the intent that is used when the AI cannot match the user input to one of your defined intents. It's also the intent name we will use internally when ChatGPT responds with something we aren't expecting, like an intent not in your list, or no intent at all but just some freeform text. Do not come up with some random name for the unknown intent though, because ChatGPT needs to understand that it means "unknown". We make this a configurable option mostly so that if you are configuring your agent in a language other than English, you can translate the word "unknown" to the language you are using. This may or may not make a difference in the performance of the AI.

    Model - this is the last configuration item we will discuss on this step. Usually, you will just leave the default - GPT 3.5 Turbo - or "ChatGPT". It is cheaper (by a lot) and faster (by a little, sometimes) than GPT-4. However, GPT-4 is dramatically more powerful, and in every single one of our tests where ChatGPT gives a wrong result, GPT-4 did a much better job. So, IF you have access to GPT-4, AND ChatGPT isn't behaving, AND you don't mind paying the price for GPT-4 or accepting the slower responses, GPT-4 is an option. If you don't see GPT-4 in the list, it's because you haven't been granted access by Open AI. If you HAVE been granted access, and you still don't see it in the list, it's because you're using an API key that was generated before you were granted access. You'll need to generate a new API key.
  5. Route to Handler Flow - This step checks to see if the detected intent is one of the intents we are handling with a separate flow. You can see this in the filter. If so, it triggers the appropriate flow and, importantly, stops the dispatcher flow. That is because a more specific flow is taking over the conversation, and you don't want them both running at once.

    Note that in the "word or phrase" we are simply passing the detected intent. That means that in your intend handler flows, the "trigger phrase" needs to exactly match one of the intents you defined. You can read about triggering one flow from another here: https://support.flowxo.com/article/273-triggering-flows-from-other-flows
    Also important is the "Metadata" - in some of our Intent Handler flows, we need to access the original user message, and we can do that through the Metadata field. You will see this in, for example, the "User Search" intent handler flow.

    Note that we're testing that the detected intent matches one of the ones we're handling with a separate flow, and if so, stops executing the dispatcher.
  6. Smalltalk Reply
    If we made it this far, then the detected user intent was not in the list of intents handled externally. So from here in our dispatcher flow forward, we're directly handling intents that are simple enough we don't need to use a separate flow to keep them organized. This is a good technique to reduce your flow counts and simplify things, but don't overuse this - working with AI can be tricky enough, if you try to put all your agents logic into one giant flow to save on using more flows, not only will it be slower, but it will be very difficult to troubleshoot and improve later once your bot is in production. We strongly recommend only keeping the simplest responses inside your main dispatcher flow, and using the "Trigger a Flow" technique for any intent that requires more than one or two steps.

    Now, back to the "Smalltalk Reply". The "Detect User Intent" step will generate a "Suggested Response" most of the time. Usually, this response is useless - it's just something ChatGPT makes up on the fly, and is not something you want to display to your users. However, the one exception is "Smalltalk" - which is things like "how are you doing today" or "tell me a joke". For these cases, the "Suggested Response" is often sufficient, so you don't need to make another call to ChatGPT to generate a new response, which will be slower and cost money if you're not on a free plan. So, for those reasons, we opted to simply send the suggested response immediately to the user, and stop the flow.

    Which brings up another point - the pattern we are using for these simple intent responses is to provide the response in one or two actions, using filters to match the action to the flow, then stopping the flow because the intent was fulfilled. Ensuring "stop the rest of the flow" is checked when you have fulfilled a user intent keeps things easy to understand.

    Pay attention to the filter we are using here. Sometimes, ChatGPT will return a "smalltalk" intent but then NOT provide a suggested response. It's just one of the many quirks of AI. Since it is an error in Flow XO to send an empty message, and since we are directly sending the Suggested Response in this step, we will ONLY execute this step if the intent is "smalltalk" AND the "Suggested Response" is not empty. That prevents the bot from failing once in a while when ChatGPT is doing something unexpected.
  7. Transfer to Human Agent
    This step is pretty self explanatory. When the detected intent is "helpdesk", then we transfer the user to an agent. You could, if you wanted, first use an Ask a Question step to ask if the user really wants that to happen, but in our example we're just immediately transferring them if the intent detector things it's what they want. 
  8. Unknown Reply
    This is the last step in our dispatcher, and it is the only one with NO filter. This is because this step executes in any situation where we did not already respond. Because of how our flow is designed, and because we handled every possible intent already, this means in practice this step will only execute when the detected intent is "unknown". However, when you are building your agents, and you make sure you include this "catch-all" step early in your process, it lets you build intent handlers iteratively while you work and get some feedback for intents that you have not yet handled. It also provides a failsafe in case you forget to handle a specific intent, that your agent won't just ignore your users message.

    Note the shortcut we defined - this is handy on the the "Unknown" step if you have live agents, because it might keep your users from getting frustrated that the bot can't understand them by letting them get to a human. When the shortcut is clicked, the phrase "Transfer me to an agent" will be sent to the bot as if the user typed it - so you need to make sure that "Transfer me to an agent" or whatever other text you decide to use for the "value" of the shortcut will be detected by the intent detector as your "live agent" intent. If, for example, you just put "A" as the value of the shortcut, when the user clicks "Agent please!" the intent detector will get the message "A" and not know what to do with it. It will probably classify the intent as "unknown" and your user will be stuck in a loop.

    Whew! That's it for the dispatcher flow. It might be time for a coffee as we covered a lot. Next, we will discuss our intent handler flows, starting with "Information Request" as this is probably the most common kind of handler you will use in your agents.

    Before we get started, I want to talk about strategy for how you design your Q&A in your agents. ChatGPT can only handle so many "tokens" (roughly words) at one time in its prompts. That means you can't just include the entire text of your knowledge base in your Q&A step. There are two common ways to address this. The first, which we demonstrate here, is having a specific "Intent Handler" flow for common questions about your company. But you may want to have many other Q&A flows for specific topics, like pricing, or sales, or whatever other areas of your business have specialized content. In that case, you will not just have a "general_info_request" intent, but also a "pricing" intent, and a "sales" intent, and any other intents that relate to the more complex topic that needs its own set of reference data. 

    The other approach is to have just one "general_info_request" step, but then use some kind of search mechanism to load the appropriate context for the Q&A step to work with. We are working on a special service for this behind the scenes, but in the meantime you can integrate with a good search app like Elastic Search, or Algolia, or any of the many other "Search as a Service" providers to look up documents based on your users query and insert them into the context of the Q&A flow. 

Building your intent handler #1 - General Info Request

Now it's time to build our first "Intent Handler". In this agent design, we have a main dispatcher that delegates more complicated intent fulfillment to specialized flows that just handle a single intent. The first of these is our "General Info Request" intent handler. It's job is to respond to general purpose questions about our company using the reference data we provide in the ChatGPT prompt. Here's the entire flow:

As you can see, this is quite a simple flow. Besides the trigger, we simply:

  1. Load a portion of the chat transcript so the AI has the conversation context
  2. Use a ChatGPT step to answer the users question
  3. Send the user the response.

We don't have any filters or labels or any other kind of branching in this flow. That's the beauty of AI, it can really do most of the hard work. This flow could be more complicated, if we needed to fetch the reference data, or context, that will be used to answer the user's question from an external source. In our case, we're just specifying it as part of the step.

Here's the trigger configuration:

What's important here is that the "Word or Phrase" exactly matches one of your pre-defined intents from the "Dispatcher" flow.

We'll also take a brief look at the Complete Chat step:

Q&A is very simple. We use the general purpose "Complete Chat (ChatGPT)" step, provide a prompt that tells the AI about it's persona, and adds some background data it can use to answer questions. Then we pass in the chat transcript so it knows the chat history, and what question the user asked. That's pretty much it.

Again, regarding the "Model" parameter - if you have access to GPT-4, it will show up as an option. Experiment with it if you are not getting the results you want from ChatGPT (3.5 Turbo). Just keep in mind it is slower and more expensive.

We discuss Q&A and various approaches in more detail here, if you want to dig into this topic a little more: https://support.flowxo.com/article/297-bringing-your-chatbots-to-life-with-flow-xo-and-chatgpt

Intent Handler # 2 - System Status

In our example agent, the System Status intent handler is actually just a simple Q&A handler, identical in nearly every way to the General Info Request handler. What we're demonstrating here is how you may have different intent handlers for Q&A on different topics. If you wanted a more useful version of this intent handler that you don't have to edit any time your system status changes, you could integrate with a "Status" service API, like Statuspage.io or any of these. You would need to get the status in an API call, then format it into a block of text you could put into the context.

Intent Handler #3 - User Search

This intent handler is a little different than the Q&A handlers. This intent handler demonstrates something many of your agents will need to do often, which is execute customer service workflows for your users, such as checking balances, processing returns, etc.

Our simple example simply pretends to execute a user search, but the important part of the flow is how we use ChatGPT to pick our our search parameters from the users input. Here's what the flow looks like:

The "Trigger" is identical to the trigger we discussed in the General Info Request handler, so we won't go over that again. Let's look at the Extract Parameters step, which is just a general purpose ChatGPT step designed to take the user's natural language command, and extract the query parameters into JSON, which we will then parse using a code step. This flow is a little more technical than the other ones, so it's helpful if you know a little JavaScript, but if not, you can usually just copy our sample and use it as is for your specific commands.

In this step, both the Prompt and the Messages are important. The prompt tells the AI what job it is supposed to complete, and provides the structure of the JSON we are expecting. We simply ask it to extract any "entities", which are named arguments, and convert them to JSON. Then, in the "Messages", rather than including chat history, we provide some example interactions along with the specific JSON we would expect in each sample case.

For tasks like this, there is rarely a need to use the more powerful GPT-4 model, using GPT 3.5 Turbo (ChatGPT) will nearly always be good enough.

The output of this step should always be a JSON object (in text format), such as

{ "name":"email", "value":"someone@somewhere.com"}

We will then process that output in the next step:

This is a very simple code step. Since we know a JSON object will be the output of the ChatGPT step, we simply add the raw output to an input (named "params"), and parse it. That's all.

In the next step, we are simply sending a message with the parsed value:

In a real scenario, you would usually use an HTTP step to call an API, passing in the parameter name and the value to perform the action. Here, we are just pretending that this is being done, and we send back a fake user in the following step:

Again, in a real scenario, we would be using the result of the HTTP call here, and would probably need some logic to do different things based on whether the result was successful. How to use the HTTP step is outside the scope of this article, but you can read about that here: https://support.flowxo.com/article/22-webhooks

In a future article, we will present a more realistic use case using a real API to get results based on the parameters, but this should get you started if you already know how to access HTTP Rest APIs. You can also use one of our existing integrations if you are less technical, and use the extracted parameters as inputs to one of those integrations, such as a Google Sheets lookup.

So, that's it for the main logic of our agent. It is already very capable, and can go a long ways towards automating some of your customer service interactions. Next, we're going to talk briefly about error handling.

Dealing with Errors

Sometimes, things will go wrong. You may try to trigger an intent handler flow with an intent you haven't handled yet, or you may have a typo in your configuration. Whatever the reason, you don't want your bot to just go silent when something goes wrong. You should always have an error handler, using our Error handling trigger type, to let the user know something went wrong. Here's what ours looks like for this example:

As you can see, it's extremely simple. Your error handlers don't need to be complicated, they just need to let your users know something went wrong. We have an extensive writeup on dealing with errors for your ChatGPT or any other kind of flow here: https://support.flowxo.com/article/241-handling-errors

Now it's time to talk about improving your bot - both debugging when things don't go as planned, and also monitoring your agents to see where you might need to add examples in your AI steps to help the bot make better decisions.

Monitoring and Improving your agents

The first thing you need to know about are the interaction logs. The interaction logs are crucial for understanding what's happening in your agents both as you are building and testing, and as you are studying real interactions with your users. The interaction logs can be found here:

Each time a flow runs, it gets an entry in the interaction log. Clicking on "Details" will show you all the inputs, outputs, and any errors for every step.

When you are building a flow, you can see interactions for just that flow by using the Flow builder context menu:

You can also easily jump from the Interaction log to the flow definition in a similar way:

You can also jump to the record for the specific user in the interaction logs:

Conversely, when you're looking at a specific user, you can see all the interactions for just that user from the context menu:

This is invaluable when studying the experience of a single user, and trying to understand which flows are executing and when.

Now let's take a look at what kind of information you can get in the logs. We'll look at a "Detect User Intent" entry from our dispatcher flow:

On the "Settings" tab, you can see all the configuration settings for that step for the current interaction:

On on the output step, you can see what the result was:

The interaction log is the best way to see what kind of result the step produced, but also what kind of data is available for you to use in your flows. For example, in this tutorial, we didn't talk about language detection. But if you look at the output above, you can see there is a "Language" output that has the language code of the user input. In this case, English, or "en". You can use this in your flow logic, to translate messages to another language for example using a Translation step from Open AI.

You can also see the intent that was detected, and also a field called "Guessed Intent". This field is interesting if ChatGPT picks an intent that wasn't in your list of intents. In the "Intent" output we convert any intent not in this list to "uknown" - but ChatGPT may have made up another intent, and you can see that here, which could give you an idea of intents your solution is missing and should be added to your agent's logic and capabilities.

The "Suggested Response" can tell you what ChatGPT is thinking about when it detected an intent. This is actually very helpful when troubleshooting, to get an idea of how you might want to add examples to fix incorrect intents.

I recommend spending a good amount of time studying your interaction logs when you are building AI flows, or any other flows for that matter. They can tell you a LOT about what is going on under the hood, and also give you ideas on data outputs you can use for your logic.

Let's look at an interaction log where something went wrong. You can easily filter the interaction logs to just failures to get a sense for where your agent is breaking, and troubleshoot the causes:

Here is what the detail on that log looks like:

You can see from the red X which step failed. It's also always the last step in the flow, since a flow stops when an error occurs. Clicking on the error tab reveals that the code step could not convert the ChatGPT response, which should have been JSON, into a real JSON object. That is a technical error, but let's see if we can see from the log what happened. Let's look at the inputs to the Complete Chat step.

We can see that the user input (other than the examples), was "What is your most popular product?"

That seems like a simple question. So what could have happened? Let's look at the output:

Look at the "Response" field - it looks OK, but it isn't. ChatGPT didn't return only JSON code, it also returned some natural language text "The user did not specify the product they are referring to". That caused the next step, which parses the result, to fail. That's not great, but wait a minute! We should not even be in the user search flow! Our users message was "What is your most popular produce" - that isn't a user search! The intent detector did not do a great job here.

Let's take a step back. Click on the "Response Path" to go to the user record, and from there choose "View Interactions" from the context menu:

We found the failure, now let's look at the interaction that happened right before that (the Intent Detection flow) to see what happened:

'The screenshots show the input and the output of the Detect user intent interaction that happened immediately prior to our failure. You can see the input, "What is your most popular product?" as expected - the output intent was "user_search". And the suggested response is made up. That's not a user search! But, as we've said, ChatGPT is usually spot on, but gets silly more than you'd like. What can we do?

This is where our examples come in. And here I wish I could give you a recipe on exactly how to fix it. But really, it takes trial and error. We know we need to add one or more examples.

We could add an example like: general_info_request[en]: What is your most popular product?

That would definitely take care of that exact situation. But, it doesn't really help other random phrases from being seen as user search intents. So sometimes you have to be creative. What we decided to do instead was give some examples of "user_search" - which has a pretty specific format - so that ChatGPT would be less likely to think any random phrase is a user search:

We added two, very specific and similar examples for the user_search intent. Then we tried again, and it worked!

Adding a couple of examples for the "user_search" intent caused ChatGPT to have a narrower understanding of what a user search looks like, and so now it properly identified "What is your most popular product" as a general_info_request, just like we wanted.

I know I'm repeating myself, but once again, working with AI is a bit of a black art, more than a science. There is no perfect recipe for coaxing the AI into behaving like you want - trial and error is required. But at least now you can see exactly what's going on under the hood, and get a sense for where and when you need more examples.

Monitor Conversations Live or Review them later

There's one more tool I want to show you that can help you monitor your agents and how your users interact with them, to get an idea of how to improve. Although you can always review user interactions in the interaction log, it can be very hard to get a sense for the flow of a conversation from there. Our "Live Chat" tool can double as a conversation monitor, even for your totally automated interactions!

See this brief screencast for a quick demo

When you navigate to the live chat, by default only ongoing agent chats are shown. However, you can switch the filter to view ALL chats, even automated ones:

Now you can review the conversational flow, across potentially several different flows, to get a complete picture of the users experience. When you see something in the chat record you want to dig into, click on the "user" field to go to the record for that user:

From there, you can navigate to the interactions for just that users chat:

Notice that you can go the other way too - from the interaction log, you can navigate to a user, and from the user, to the live chat record to view the whole conversation:

So that's it for our sample agent! I hope you found this helpful - you should now be able to create powerful AI agents using ChatGPT for your own business and host them on any channel where your customers interact using Flow XO.

As always, we love feedback - good or bad. Also feel free to let us know if there are other samples or tutorials you would like to see. Just reach out to us at support@flowxo.com

Happy flowing,

The Flow XO

Still need help? Contact Us Contact Us