Welcome to the second part of our series on building powerful, ROI-driving AI apps. In the last post, we covered considerations around the AI stack and deployment—and some of the challenges you might face building and operating as quickly as you’d like. In this edition, we’ll explore ways to introduce more flexibility and speed into your process without cutting corners, allowing you to go from proof-of-concept to production-ready AI applications confidently. Let’s walk through a step-by-step tutorial on building your first AI app in Retool.
Why an AI chatbot? According to Retool’s 2024 State of AI report, 55.1% of people building AI apps have either built a chatbot or their company has. Another 46.5% think chatbots will be popular for a while. Let’s start with the basics and build a Q&A chatbot from scratch.
(If you aren’t currently a Retool user, you’ll want to create a free account to follow along.)
Once you’re set up with a Retool account, start building by adding whichever data source you want to use to Retool. Navigate to your dashboard and use either UI components or Workflows. In this example, we’ll use Retool Vectors, where you can use a Retool-managed or third-party vector database to build a Q&A chatbot with your own data.
![](/blog/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2F6715a4032705852ae9d6b23cdfa311c222eab175-1999x935.png&w=3840&q=75)
Here, we have an upload component that allows a user to either upload data via text input or upload via an application/pdf
mime type. If you choose PDF, Retool will parse the PDF and then upsert it into the Retool database.
From there, Retool Vectors will take over. Retool Vectors combine the embedding process and the vector database, upserting, storing, and querying from above. Under the hood, Retool Vectors is using OpenAI embeddings, but all the process is abstracted away:
![](/blog/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2F0c4f63a0bbabca48f6fc8bb0d83d2e7e92c065a9-1999x846.png&w=3840&q=75)
The embeddings stored in the Retool Vector database can now be used in the same way as the embeddings above.
Now, we can create a chat interface using a pre-built chat component and attach a simple Retool AI query.
Retool AI allows you to use various AI models within your Retool applications. Here, we’ll use GPT-4o, but you can try any number of other models, like Claude, Gemini, Llama3, or Mixtral to find the right fit for your use case. (You can switch between them pretty darn seamlessly too—just use the Model dropdown to select your preferred LLM!)
All we need to do is pass it the lastMessage
in the chat, the messageHistory
from the chat, and our vectors for more context, along with a system prompt:
![](/blog/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2F793de555efb6168ea2553deb958c3308dae76028-996x1312.png&w=3840&q=75)
When this query is run, the matching embeddings are selected from our vector database and then sent with the query to our model to generate our answer:
![](/blog/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2Fe1e5c3f1d36e6ce2e275c45ae3de2ea38effc5ec-1600x751.png&w=3840&q=75)
We just bypassed all the extra code and infrastructure from part one of this series. You’ll still get the benefits of scalability, reliability, and flexibility of a microservices architecture, but without the complexity and troubleshooting hassles of your own deployment. And you can immediately deploy this application to users.
This allows you to go from proof-of-concept to a working application far more quickly than building out every part of your application from scratch.
Once you’ve built a working AI application, you can easily use Retool to experiment with and see how different LLMs might produce different results. You can change the model that a particular query uses with a single dropdown.
For example, you could build a Retool app, like the one in the image below, that takes the same prompt and shows you the output from four different models at the same time.
![](/blog/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fbclf52sw%2Fproduction%2F465b3a19d7bb28bf3f40b5213790ff076cdbc2a8-800x517.gif&w=3840&q=75)
With this ability to test and research, you’ll be able to iterate on your Q&A chatbot to find and choose the most suitable model, test your prompts, and fine-tune them as needed.
Layering in AI can transform what’s possible within your apps. With Retool, you can build a working AI app more efficiently in less time and with fewer engineering resources.
This tutorial is just the start. If you’re ready to keep exploring the possibilities of AI-powered tools for your team, here are a few more useful resources:
You can sign up for Retool and start building your first AI apps with Retool AI and Retool Vectors, or you can contact us to learn more about how Retool can help you build your AI applications.
Don’t forget to follow @Retool on X and show us what you’re working on. Happy building!
Reader