Web Agent guide
The Web Agent is an AI chat assistant that lives on your website and answers visitors in real time. This guide walks you through configuring it in the dashboard and installing it on your site yourself — step by step, no developer needed.
The whole idea in one line
You configure the agent once in your Safqat dashboard, then paste a short code snippet into your website. A chat bubble appears for your visitors and the AI answers their questions from the knowledge you provided.
The Web Agent is a chat widget you embed on your website. It greets visitors, answers their questions instantly using your uploaded knowledge base, replies in their language, and hands the conversation over to your team whenever a human is needed. Every conversation, rating, and lead is captured in your dashboard.
Open your Safqat dashboard and go to Web Agent → Setup. A guided 7-step wizard walks you through everything below. You can change any of these later from Web Agent → Settings.
Step 1
Pick the main language your agent speaks (Arabic, English, French, and 11+ more) and the focus area that best fits your business — customer service, sales, support, or feedback. This shapes how the agent introduces itself and replies.
Step 2
Enter your business name (shown to visitors), optionally upload your logo, and choose a tone of voice.
Step 3
Provide four agent names. These are the friendly names visitors see in the chat (for example a greeting from "Sarah"). The wizard pre-fills sensible names for your chosen language — keep them or change them.
Step 4
Pick a primary color that matches your brand and choose light or dark mode. This controls how the chat bubble and window look on your site.
Step 5
List the website domains where the agent is allowed to run (for example yourstore.com). This protects your agent so it only works on sites you own.
Step 6
This is what makes the agent smart. Upload documents or paste text describing your products, policies, hours, shipping, returns — anything customers ask about. The agent answers from this content.
Step 7
Write the first message visitors see when they open the chat, review your settings, then activate the agent. The final screen also shows your install code — that's what you'll use in Part 2.
Once your agent is active, installing it is a copy-and-paste job. The snippet is two short lines of code that load the widget and connect it to your agent.
Go to Web Agent → Settings → Integration Code (it's also shown on the last step of the setup wizard). Click the copy button to grab your snippet — it already contains your unique agent ID.
Your snippet looks like this:
<script src="https://cdn.safqat.ai/widget.js" data-safqat-api-base="https://safqat.ai"></script>
<script>
Safqat.init({
agentId: "your-agent-id",
apiBase: "https://safqat.ai"
});
</script>Copy your snippet from the dashboard
Use the copy button so your real agent ID is included. The example above uses "your-agent-id" as a placeholder — yours will be a unique value.
Paste it into your website
Add the snippet just before the closing </body> tag on every page where you want the chat to appear. On platforms like Shopify, WordPress, or Wix, paste it into the "custom code" or "header/footer scripts" section so it loads site-wide.
Publish and refresh
Save and publish your site, then reload the page. A chat bubble appears in the corner — click it to start a conversation.
If your site has accounts, you can pass each visitor's details so conversations are tied to the right person. Only do this for visitors you actually know (e.g. after login).
Safqat.init({
agentId: "your-agent-id",
apiBase: "https://safqat.ai",
user: {
id: currentUser.id, // unique per visitor
hash: currentUser.safqatHash, // signed on your server (below)
name: currentUser.name,
email: currentUser.email,
// Optional: properties (shown in People, usable by the AI and for targeting)
properties: { plan: currentUser.plan, orders: currentUser.orderCount }
}
});Important: use each visitor's own unique id. Never paste one fixed id for everyone — if you do, all visitors will share the same conversation.
Sign the id on your server so nobody can open a visitor's chats by guessing it: put the HMAC-SHA256 of user.id, keyed with the identity secret from Web Agent → Settings → Identity verification, in user.hash. Without a hash, ids that are numbers, emails or short strings get a private key per browser instead, so their history doesn't follow them to other devices.
// Node.js — the secret never leaves your server
const crypto = require("crypto");
const safqatHash = crypto
.createHmac("sha256", process.env.SAFQAT_IDENTITY_SECRET)
.update(String(currentUser.id))
.digest("hex");Everything here is optional. Use it when your site is a single-page app, has its own login, or wants to open the chat from its own buttons.
This version loads the widget without slowing your page and queues any Safqat(…) call made before the script finishes loading, so you can call commands right away from anywhere.
<script>
(function (w, d) {
w.Safqat = w.Safqat || function () {
(w.Safqat.q = w.Safqat.q || []).push(arguments);
};
var s = d.createElement("script");
s.async = true;
s.src = "https://cdn.safqat.ai/widget.js";
s.setAttribute("data-safqat-api-base", "https://safqat.ai");
d.head.appendChild(s);
})(window, document);
Safqat("init", { agentId: "your-agent-id", apiBase: "https://safqat.ai" });
</script>Every command works both as a method (Safqat.open()) and as a queued call (Safqat("open")).
Safqat.open(); // open the chat (Messages tab)
Safqat.close();
Safqat.toggle();
Safqat.hide(); // hide the launcher (e.g. you use your own button)
Safqat.show(); // bring the launcher back
Safqat.showNewMessage("I have a question about my order"); // open with text prefilled
// Who the visitor is (login, user switch, language change)
Safqat.update({ user: { id: user.id, name: user.name, email: user.email }, locale: "en" });
// Properties for this visitor — merged; null deletes a key
Safqat.setProperties({ plan: "pro", seats: 5, trialEndsAt: null });
Safqat.shutdown(); // logout: remove the widget and forget this visitor
// Events: "ready" | "open" | "close" | "unreadCountChange" | "message"
const off = Safqat.on("unreadCountChange", ({ count }) => updateBadge(count));
off(); // stop listening
// Conversions (thank-you / order-complete page)
Safqat.trackConversion({ agentId: "your-agent-id", orderId: "1042", amount: 49, currency: "USD" });Properties show up on each person in People and can be used to target announcements. Keys use letters, numbers, spaces, dots, dashes or underscores (up to 40 characters). Values can be text, numbers, true/false or short lists. Set a key to null to remove it.
When a visitor signs in, tell the widget who they are with update and send account details with setProperties. On logout call shutdown so the next person on this browser starts with a fresh, anonymous chat.
// React example — run whenever your auth state changes
useEffect(() => {
if (!user) return;
Safqat("update", {
user: { id: user.id, name: user.name, email: user.email },
});
Safqat("setProperties", { plan: user.plan, stations: user.stationCount });
}, [user]);
async function handleLogout() {
await signOut();
Safqat("shutdown"); // forget this visitor on this browser
// Optional: keep the chat available for anonymous visitors
Safqat("init", { agentId: "your-agent-id", apiBase: "https://safqat.ai" });
}Before telling customers about it, do a quick check on your live site: