5 AI Studio Techniques Every Low-Code Developer Should Know
最終更新日 November 21, 2024

Introduction

When working with AI Studio, there are a few useful flows that come up time and again. In this article, you will learn how to improve your Conversational AI Agents with 5 simple but powerful flows that are useful in every agent!

You’ll learn how to create a flow to send emails,  how to organize your agent to be nice and neat, how to create a loop to accept multiple questions from your user, how to handle broad questions that might confuse your agent, and finally how to create fallbacks if the user gives troublesome questions!  

Prerequisites

  • Vonage API Account

Vonage API Account

To complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.

You must set up a basic Inbound WhatsApp agent to follow along. First, to create your agent, follow the instructions found in the AI Studio documentation. There are three important options for our agent, select:

  • Type: WhatsApp

  • Template: Start From Scratch

  • Event: Inbound

Then add the following 3 nodes:

  • Send Message Node: send a greeting to our user

  • Collect Input Node: collect a user question and store to a parameter called $user_query, this will be referred to as Collect User Query

  • Classification Node: classify for $user_query, this will be referred to as Main Classification

Starting Boilerplate WhatsApp FlowStarting Boilerplate WhatsApp Flow

How to Use the Send Email Node in AI Studio

Allowing users to email your company from a Conversational AI agent offers a reliable and secure communication channel that users trust, ensuring inquiries are handled professionally. Additionally, it allows your team to manage responses at their own pace, integrating seamlessly with existing workflows since email is already widely used within most organizations.

You’ll first need to create an Email Support Intent for our classification node. Intents are how the AI agent knows the purpose of your user’s question and which flow to route them to.

Open the Classification Node and click Create Intent. Name the intent “Email Support” at the top and then add 5-10 user expressions like “Email help”, “Email support”, and “I want to email support”. User expressions are the data that help train the agent to understand different intents.

Intent Training Set for Send Email FlowIntent Training Set for Send Email Flow
Next, we’re going to need 2 additional pieces of information from the user before we can use the Send Email node:

  • Collect Address

    • Using a Collect Input node, ask the user for their email address.

      • E.g., “Great! Can I have your email address?”

    • Store it inside a new Parameter $email_address.

    • Set this parameter to @sys.email so that AI Studio will only accept valid email addresses.

  • Collect Email

    • Using a Collect Input node, ask the user for the question that was unanswerable by the agent

      • E.g., “Please explain the question you have, and I'll pass it along to support 💌

    • Store it inside a new Parameter called $email_content

Now we are ready for the Send Email node. The configuration for our node will be:

  • To: add your email here

    • Make sure to hit enter so that the address is saved. It should turn into a grey block.

    • You can add more than one email recipient.

  • Subject: New AI Agent Question: $PROFILE_NAME

    • $PROFILE_NAME is a System Parameter that allows us to access the user’s profile name they set in WhatsApp. (Note: not everyone uses their real name as a profile name.)

  • Body:

Contact Info:

  • Respondent Name: $PROFILE_NAME

  • Respondent Phone Number: $SENDER_PHONE_NUMBER

  • Respondent Email: $email_address

User Submitted Question: $email_content

Conversation Time: $CONVERSATION_START_TIME

Your node should look like this:

Send Email NodeSend Email Node
Great! Our Email flow is now complete. You can now use the Chat Tester and try it out with your email address!

How to Organize Your Agents With Subflows

Our canvas is starting to get a bit messy, and this is just for a short flow! Imagine with flows that can be dozens of nodes! To keep our agents clean, we can organize them with subflows.

Protip: Start with a Mockup before building and organizing is much easier

To create a new flow, click the Flows tab in the most leftward panel. Then click Add flow. You can rename your flow to Send Email by right-clicking.

How to Rename SubflowsHow to Rename SubflowsNow recreate the Email flow portion from before; everything after the Classification node (Collect Address node, Collect Email node, Send Email node). However, now use the Start node in your new sub-flow, as your beginning.. You can duplicate your previous nodes and copy/paste them into the subflow.

Now, from the Flow Control section of the Node panel, add an Exit Flow node. Click on the node and rename it Exit Send Email. We can now use our subflow to clean up our Main Flow! Click on the Events tab (the one with the lightning bolt) and then click on Inbound Session. This will bring you back to our Main Flow.

Now delete all the nodes we created in the previous section How to Use the Send Email Node (everything after the Classification node).  Next, from the Flow Control section, add a Flow node and select the Send Email Flow. You can connect your Classification node to the Send Email Flow node, and that’s it! Your agent has the same functionality but in a much cleaner way.

Agent Main Flow with Send Email SubflowAgent Main Flow with Send Email Subflow

How to Loop for Multiple User Inquiries

Our email flow is nice, but what if the user wants to email support and ask more questions? We don’t want them to start the whole agent over! We want to allow the user to ask our chatbot multiple questions. 

Create another subflow called “Repeat?”. Add a Collect Input node called Collect Repeat that will save a new Parameter called $repeat of type @sys.confirmation. The node will receive Reply Button inputs. One button should have a title Yes and a value of yes. The other button should have a title of No and a value of no.

Collect Repeat Node DetailsCollect Repeat Node DetailsNow, we’ll use a Condition Node to check against $repeat. Create one condition to check if $repeat is equal to yes, and another to check if $repeat is equal to no. Now add two separate Exit Flow nodes; one for REPEAT = YES and another one for REPEAT = NO.

Complete Repeat? SubflowComplete Repeat? SubflowNow, back in our Main Flow, we’ll finish our repeat logic. Connect the yes condition again to your original Collect User Query node, the first collect input node we used.

So that our users know the flow is over, and our agent is “asleep”, let’s create one final Send Message node with a simple Goodbye Message, “Thanks for using AI Studio!” Connect our false condition to this node. Connect the Goodbye Message node to an End Conversation node.

Repeat? Subflow Within the Main FlowRepeat? Subflow Within the Main Flow

How to Handle for Broad User Queries

The rest of the article all takes place in our main flow.

So far we’ve created one intent for our users: sending emails. Your agent may have many intents. Sometimes, users may ask broad questions that match multiple intents, confusing the virtual agent. Instead of the agent saying, “I’m sorry, I didn’t understand that,” which can frustrate users, a better approach is to create a “Broad Queries” intent. This intent gives a polite, clarifying response and prompts the user to rephrase, helping maintain their confidence in the agent’s ability to assist.

Broad queries for a travel booking agent may look like “flights,” “assistance,” “details,” “booking question,” etc.

Intent Training Set for Broad QueriesIntent Training Set for Broad QueriesFirst, add a “Broad Queries” Intent to your Main Classification Node. Then add possible broad queries in the User Expressions field. Try to add possible words or phrases that might confuse an agent and end up in multiple intents.

Second, create a new Collect Input node and connect to it from the Broad Queries intent. We’ll use this Collect Input node to collect our $user_query parameter. However, here we’ll say something like, “That’s a great question! Can you be more specific?” or, “I’m happy to help. What’s your question?”.Lastly, loop back to your Classification Node.

Overview of Broad Queries LoopOverview of Broad Queries Loop

How to Create Fallbacks for Unexpected User Input

When handling user input, a few common errors can occur. For instance, when using a Collect Input node in WhatsApp, users may enter text when the Agent expects an Image. Or they may send an empty message. Additionally, Classification nodes may get confused if an inquiry doesn’t match existing intents. We’ll build two fallback flows to cover these two potential scenarios.

How to Create a Fallback Flow for Unexpected Input Type

Our first Collect Input node expects users to submit a question as text. We can create a fallback for by adding a new Collect Input node called Fallback:Text. The value is stored again to $user_query and the prompt is “Sorry, questions must be typed. Please ask again.” Then, this node can be connected to our Classification Node and the Unexpected Input Type exit point.

Fallback for Unexpected Input TypeFallback for Unexpected Input Type

How to Create a Fallback Flow for Misclassification

In our Classification node, we need to handle the Missed case. We can again add a new Collect Input node called “Fallback: Missed Intent”. The value is stored again to $user_query. The prompt is, “Sorry, I didn't understand that. Please try a more detailed question.” Then this node is connected back to our Classification node.

Missed Classification Fallback FlowMissed Classification Fallback Flow

How to Avoid Endless Loops in Fallbacks

You might have noticed that these fallbacks have a potential pitfall. If the user gave problematic input the first time, why wouldn’t they give problematic feedback in our follow-up question? They could! And they would end up in an endless loop. Learn how to avoid endless loops with a well-structured fallback flow.

Conclusion

And that’s a wrap! 5 simple but powerful AI Studio flows that can really level up your conversational AI agents. By setting up email functionality, keeping things tidy with subflows, allowing users to ask multiple questions, handling those tricky broad queries, and creating smart fallbacks, you can build more responsive and user-friendly agents.

These tips are all about making your life easier as a low-code developer while ensuring your users have a smooth experience. So go ahead, give these flows a try, and see how they can make your agents smarter and your workflow cleaner. Have fun experimenting with AI Studio, and be sure to let us know what you are building. Please reach out in our Developer Community Slack or on X, formerly known as Twitter.

Benjamin AronovDeveloper Advocate

Benjamin Aronov is a developer advocate at Vonage. He is a proven community builder with a background in Ruby on Rails. Benjamin enjoys the beaches of Tel Aviv which he calls home. His Tel Aviv base allows him to meet and learn from some of the world's best startup founders. Outside of tech, Benjamin loves traveling the world in search of the perfect pain au chocolat.

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.