- Published on
Making a User-Friendly, Smart, and Secure AI Assistant Chatbot
- Authors
- Name
- Nico Prananta
- Follow me: @2co_p
I recently put together a demo of an AI Bank assistant chatbot using Vercel's AI SDK and gpt-4o. This chatbot uses two main tools: transferMoney
and getBalance
. Here's a breakdown of what makes it user-friendly, secure, and how easy it is to implement.
Smart Information Handling
One of the nice features of this chatbot is how it handles information. Whether you prefer to enter your details bit by bit, all at once, or step-by-step, the chatbot can manage it.
![](/_next/image?url=%2Fstatic%2Fimages%2Farticles%2Fai-sdk-chatbot-1.png.webp&w=3840&q=75)
It won't execute the task until it has all the required information, making the interaction feel more natural and less like filling out a form. I absolutely believe that this is an important user experience when it comes to AI chatbots.
Implementing this kind of smart information handling can be quite challenging with other tools like Langchain, Dify, or Rasa AI, as they often require more complex setup and management of dialogue flows.
Here’s a prompt to tell the LLM to collect the required information until it has all the details:
- transferMoney: Schedule the money transfer. This tool and the parameters' collection must only be called if the user has verified their account via OTP verification. Call the transferMoney tool only when you have all required parameters. Otherwise, keep asking the user. Don't come up with the information yourself. Once you have the complete information, ask the user to confirm the transfer before calling the tool by showing the transfer information.
Enhanced Security
Security is crucial, especially for banking transactions. To address this, the chatbot includes two extra tools: verifyPhoneNumber
and verifyOTP
.
- verifyPhoneNumber: Requires your account information and phone number. It then sends a 4-digit OTP to your phone.
- verifyOTP: You enter the OTP you received. If it's correct, you can proceed with transactions.
These steps ensure that only verified users can perform sensitive actions like transferring money. The verification process in the demo is simple where the verifyOTP
function simply checks if the phone number that the user provided belongs to the user with the given account information, and if the entered OTP is correct.
![](/_next/image?url=%2Fstatic%2Fimages%2Farticles%2Fai-sdk-chatbot-4.png.webp&w=3840&q=75)
Here’s the prompt to tell the LLM to verify the account:
Some of the actions require the user to verify their account first by providing a verification code (OTP) sent to their phone number. The verification code is valid only when the user enters it correctly. If the verification code is invalid, the user needs to request a new verification code. Subsequent verifications are required when the last verification was more than 3 minutes ago.
- verifyPhoneNumber: Verify the phone number of the account. Only collect the parameter to call this tool when the previous tool call requires phone number verification. And then call the verifyPhoneNumber tool only when you have required information. Otherwise, keep asking the user. Don't come up with the information yourself. Once you have the complete information, ask the user to confirm the request before calling the tool by showing the request information.
- verifyOTP: Verify the OTP sent to the user's phone number. If the OTP is valid, perform the next function. Otherwise, ask the user to request a new OTP.
Flexibility in Requests
The chatbot is also quite flexible. If you initially request a money transfer but then decide to check your balance instead, it adapts accordingly. This ability to change directions based on user input makes it more user-friendly.
![](/_next/image?url=%2Fstatic%2Fimages%2Farticles%2Fchat-02.png.webp&w=3840&q=75)
I think such flexibility in handling dynamic requests is part of the capabilities of the model I used which is gpt-4o from OpenAI.
User Confirmation
Before executing any task, the chatbot confirms the details with you. This gives you a chance to review and modify any information if needed. It ensures accuracy and peace of mind.
![](/_next/image?url=%2Fstatic%2Fimages%2Farticles%2Fai-sdk-chatbot-3.png.webp&w=3840&q=75)
Check out this prompt to instruct the LLM to show the confirmation step in action:
Once you have the complete information, ask the user to confirm the request before calling the tool by showing the request information.
Ease of Implementation with Vercel AI SDK and gpt-4o
With Vercel AI SDK and gpt-4o, building this chatbot was quick and painless, making it accessible even if you’re not an AI expert. The ease of prompt engineering and seamless function/tool definition and calling allows for a smooth development experience, ensuring powerful and responsive AI interactions. And with the recent maxAutomaticRoundtrips feature, feeding the result of the function calls back to the model is no hassle at all.
Conclusion
Overall, I really enjoyed building this AI Bank assistant chatbot. The development experience was top notch unlike my experience with Langchain caused me to think that I had skill issue.
You can check the repositories of this chatbot here and the demo video here.
By the way, I have a book about Pull Requests Best Practices. Check it out!