Add a Gemini AI prompt for your Retool app
This tutorial will show how to create a Gemini AI prompt that you can add to your Retool app. Have Retool ready and a Google AI Studio account, and let's get started.
Prerequisites
You will need:
- A Weavy API key
- A Retool account
- Weavy components installed in your Retool account
- A Google AI Studio account
1. Weavy API key and backend
First we need an API key to communicate with the Weavy backend. You can find your API key and backend URL in your Weavy account.
2. Gemini AI API Key
To connect the bot to Gemini AI, we need an API key. Log in to your Google AI Studio account and find or create an API key.
3. Name the bot
The bot needs a display name (what the end user sees) and a unique identifier required when rendering our messenger in bot mode.
The unique identifier (uid) is also used to update the bot through the Web API, etc.
4. Create the bot
Now it's time to create the bot in Weavy through the API using CURL with your provided information.
curl WY_BACKEND_URL/api/users -H "Authorization: Bearer WY_API_*****************" --json "{ 'uid': 'BOT_UID', 'name': 'BOT_NAME', is_bot: true, 'metadata': {'family': 'gemini', 'api_key' : 'GEMINI_API_*****************'} }"
Note Replace
WY_BACKEND_URLandWY_API_*****************with your Weavy backend URL and API key.
This will create a bot user in Weavy using Gemini AI.
5. Get access token
For our Weavy component to work, we need an access token from the authentication workflow.
Go to Code in the left panel, click the + and select Import Workflow
- Name it
getWeavyToken - Select
WeavyAuthenticationfrom the Select Workflow dropdown - Click the
Reset to Example JSONinWorkflow parameters - Change the
Run behaviortoAutomatic - Click
Save & Run - If successful, you should see an access token in the output window
Note You need to import the workflow and install the Weavy components for this tutorial to work.
6. Add AI prompt
Search for Weavy Messenger in the components search bar, drag and drop it onto the canvas.
Select the Weavy Messenger component and in the Inspector find the property Bot; copy and paste the value below.
BOT_UID
7. Done!
The Weavy Messenger with bot mode enabled should load instantly - but toggle to Preview mode to see the full experience.
Note that this is fully working now and available for all your users if you want - AI prompting added, just like that.