AI Auto-Reply
Use Google Gemini AI to automatically respond to visitors in your chat widget. Configure custom instructions to control the AI's behavior, tone, and knowledge.
Setup
- Go to Dashboard → Chat Settings → AI Auto-Reply
- Toggle AI Auto-Reply on
- Enter your Gemini API Key from Google AI Studio
- Write your Agent Instructions (or choose a preset template)
- Set max replies per conversation
- Save settings
Agent Instructions
Instructions tell the AI what to do, how to behave, and what information to share. Be specific about your product, tone, and boundaries. FloatMessage provides preset templates for common use cases:
Max Interactions
Set a limit on how many AI replies per conversation (default: 10). After this limit, the AI stops replying and you can take over manually from the dashboard.
Admin Takeover
When you send a manual message from the Dashboard chat, AI auto-reply is automatically disabled for that conversation. This prevents the AI from interfering while you're personally handling the conversation.
- Visitor sends a message → AI auto-replies as configured
- You open the conversation in Dashboard → Live Chat
- You type and send a reply manually
- AI auto-reply is permanently disabled for this conversation
- All future visitor messages in this conversation go only to you
This is a per-conversation setting. Other conversations with the same visitor (or other visitors) continue to use AI auto-reply normally.
Instruction Sources
| Mode | Description |
|---|---|
| Static Only | Uses the instructions you write in the dashboard |
| Webhook Only | Fetches dynamic instructions from your server for each conversation |
| Webhook + Fallback | Tries webhook first, falls back to static instructions if webhook fails |
Webhook Configuration
When using Webhook or Webhook + Fallback mode, your server receives visitor context and returns personalized instructions.
Webhook Payload
POST your-webhook-url
Headers:
Content-Type: application/json
X-FloatMessage-Signature: sha256=<hmac>
Body:
{
"event": "conversation.instructions",
"conversationId": "abc123",
"visitor": {
"id": "vis_xyz",
"name": "John",
"email": "john@example.com",
"country": "US",
"city": "San Francisco",
"userAgent": "Mozilla/5.0...",
"pageUrl": "https://example.com/pricing",
"customData": {
"userPlan": "enterprise"
}
}
}Expected Response
{
"instructions": "You are a VIP support agent...",
"maxInteractions": 20
}Webhook Security
Optionally set a Webhook Secret to verify requests. FloatMessage signs the payload with HMAC-SHA256 and sends the signature in the X-FloatMessage-Signature header.
Client-Side Variables
Collect JavaScript variables from the visitor's browser to send to your webhook. For example, window.userPlan or myApp.user.tier. These values appear in the webhook payload under visitor.customData.
Template Variables
Personalize AI instructions per visitor using ${variableName} placeholders. These are replaced with real visitor data before the AI generates a response.
Built-in Variables
These are automatically collected for every visitor — no configuration needed.
| Variable | Source | Example |
|---|---|---|
| ${country} | Cloudflare geolocation | US |
| ${city} | Cloudflare geolocation | San Francisco |
| ${userAgent} | Browser User-Agent header | Mozilla/5.0... |
| ${pageUrl} | Current page URL | https://example.com/pricing |
| ${visitorName} | Pre-chat form (if enabled) | John |
| ${visitorEmail} | Pre-chat form (if enabled) | john@example.com |
Custom Variables
You can collect custom data from the visitor's page in two ways:
1. Dashboard Configuration
Add JavaScript variable paths in Chat Settings → Template Variables → Custom Variables. The embed script reads these from the visitor's page automatically. The last segment of the path becomes the variable name.
// If you configure: window.userPlan
// And your page has:
window.userPlan = "enterprise";
// Then in your AI instructions you can write:
"The visitor is on the ${userPlan} plan. Tailor your response accordingly."2. JavaScript API (Programmatic)
Use FloatMessage.setCustomData() to pass custom data programmatically. This is useful when the data isn't available as a simple window variable, or when it changes dynamically. Requires the JavaScript API to be enabled.
// Pass any key-value pairs
FloatMessage.setCustomData({
userPlan: "enterprise",
cartTotal: "249.99",
accountAge: "2 years"
});
// These become available as template variables:
// ${userPlan}, ${cartTotal}, ${accountAge}
// And in webhook payload as visitor.customDataYou can call setCustomData() at any time. It merges with any variables already collected from the dashboard-configured paths and sends the updated data to the server immediately.
Example: Personalized AI Instructions
You are a support agent for MyStore.com.
The visitor is from ${city}, ${country}.
They are on the ${userPlan} plan with a cart total of $${cartTotal}.
If they are on the "free" plan, mention our Pro upgrade.
If their cart is over $100, offer free shipping with code FREESHIP.
Be friendly and concise.Note: If a variable has no value (e.g. the visitor's browser doesn't have window.userPlan set), the placeholder stays as-is in the instructions — the AI will see the literal ${userPlan} text.