Introduction
One of the riskiest coding practices is writing large chunks of code without periodically testing to ensure everything functions as intended. The same principle applies to no-code/low-code! Thankfully, AI Studio has a built-in tester to ensure your code is working at each step.
This article will show you how to get started with the AI Studio tester for WhatsApp agents and avoid some common pitfalls.
Prerequisites
Sign up for a Vonage API Account
Try building an agent; check out our tutorials to get started
DT API Account
To complete this tutorial, you will need a DT 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 DT API Dashboard.
How to Use AI Studio’s Built-In Tester
The first step is opening the tester inside your Agent’s Canvas. Click the big black button at the top right of the canvas that says Tester. This will open the Tester. You can choose which event to test (if you have multiple) and whether to test in the AI Studio Canvas or directly inside WhatsApp.
Note that test chat in WhatsApp is temporary and you will still need to purchase a number and publish an agent for public use of your agent.
A screenshot of the AI Studio built-in tester interface, allowing users to start a chat or test an agent directly in WhatsApp.Click on the “Start chat” button, and as long as you have some conversation nodes connected to your agent, you can immediately start interacting with the agent. How cool!
How to Use Testing Parameters
The most important feature of the tester is the ability to use test parameters/variables. Test parameters help us identify whether agent errors are due to flow logic or bad inputs. To access test parameters, click on the gear/settings icon at the top of the Tester window. To close the pane, click on the gear icon again.
AI Studio showing a chatbot flow and the tester being opened to start a test session.Agent flows often rely on user data (like the user’s phone number) to integrate with external systems. We can add test parameters for these types of variables under System parameters. Additionally, variables created specifically for your agent will appear under Custom parameters Setting values for test parameters is very useful for debugging integration nodes like the Webhook node or the Salesforce nodes.
Consider the following Webhook node, which connects the agent to a Google Sheet. Setting up the integration is a bit advanced and may result in many different types of errors; the code in the Google Apps Scripts, a malformed request URL, an incorrect query parameter, or something else.
A screenshot of an AI Studio Webhook node configured to retrieve a price using a GET request with a query parameter.You can see that we have the “Test request” button in the Webhook node. However, if we hit send, we’ll get the following error:
"error": "Item not found."
That’s because our request looked like this:
https://script.google.com/macros/s/AKfycbw5hzozzPWXB6-3f27iYA2-ug-rnJwl22ZdEXaBdemuPC4pds9NLzAC5mAQmDGMqfs/exec?item=
The item was blank! Thankfully we can correct this by opening our test parameters by clicking the gear icon and updating it to a value we’re sure exists in our spreadsheet. And now we can see that we received a good response!
A screenshot of AI Studio's test parameters panel and webhook test request, showing how setting an initial parameter affects the response.
Tip: A common data issue is passing strings when expecting numbers and vice versa. Using test variables can help identify this quickly.
Refreshing the Tester
Users often make updates, like changing test parameters, and see no difference in the agent’s test performance. That’s because they haven’t refreshed the tester to get the latest version. If you have the tester open, you’ll need to click the refresh icon before running a new test flow.
AI Studio showing a chatbot test session where a user interacts with an agent to retrieve a price.
How to Debug Unexpected User Behaviour
You might run into errors once you’ve started running your agent flow in the tester. That’s normal! Each chat bubble in the tester has two icons. The first external link icon will adjust the canvas to show you the node responsible for that output. The second code icon will open up the Debug window which displays the JSON code of the flow execution.
In the following example, you can see how useful the Debug window is. In this chat, we enter the input “banana” and the webhook seems to execute without errors. However, we don’t get a price for the display.
A screenshot of an AI Studio chat session where a webhook executes successfully, but the agent fails to return the expected price.Our first step is to make sure the Send Message node displays our parameter correctly. So let’s set our parameter price to 100. And as we can see, now the price is displayed as $100. So something must be happening in the Webhook node.
AI Studio's test parameters panel being used to define values for debugging a chatbot flow.
This time, we can open the Debug window by clicking on the code icon in the webhook message. This opens the JSON log of everything that’s been executed thus far in our agent. We can search for “web” to find the node in question more easily. And here we find the culprit!
Tip: searching for 'error' makes it easier to pinpoint the correct error when multiple things go wrong.
AI Studio's tester showing a chatbot conversation where a webhook executes successfully, but the agent fails to return a price, requiring debugging.Although the webhook node's status shows "SUCCESS," the message we receive in the "text" field does not contain a price. Instead, it shows:
{"error":"Item not found."}
And that makes sense because banana is not in our spreadsheet.
Tip: To more quickly find your error, use ctrl+f or cmd+f
How to Test on WhatsApp
The built-in tester allows you to test your agent directly on WhatsApp! It’s also the recommended way to test because it’s the closest to reality, as some functionality might be missing in the Studio tester.
Open the Tester and this time click “Test in Whatsapp”. This will open a screen with a QR code and link. Either scan the QR code with your phone or click the link. This will open a chat with a test version of your agent.
Begin the chat by sending the generated passphrase. After that, your agent will run according to the flow. You can even share the link to the chat to have others test the agent.
Note: Test chats expire, with a maximum of 24 hours. You may need to regenerate the chat by reopening the tester and rescanning the QR code/link. However the test chat will not work as a production agent, you will need to publish your agent for it to work.
A screenshot of the AI Studio tester interface displaying a QR code for testing an agent in WhatsApp.
Conclusion
Now that you’ve seen how to use and debug with the built-in Tester in AI Studio, there’s nothing stopping you from building amazing WhatsApp chatbots. We have a wide selection of AI Studio tutorials or create your own integration and tell us about it. If you get stuck or can’t figure out how to get around a bug with the tester, drop me a message on the Vonage Community Slack. We even have a dedicated channel for AI Studio.
)
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.