JavaScript API for your website
Once the one-line script is on your page, a small Techvea object lets your own page control the chat. It works from any site, including single-page apps.
| Techvea.open() / close() / toggle() | Open, close or flip the chat window. |
| Techvea.hide() / show() | Remove the chat button from the page, or bring it back (for example on a checkout page). |
| Techvea.identify({ id, name, email, attributes }) | Tell the bot who is visiting. It uses it to personalize answers, fills the contact form for them, and saves it with the conversation and any ticket. |
| Techvea.track(name, props) | Tell the bot about something the visitor did. The last few events are sent along with their next message. |
| Techvea.on(event, fn) / off(event, fn) | Listen for open, close, message (the bot answered), handoff (a person is needed) and lead (details left). |
Open the chat from your own button
HTML
<button onclick="Techvea.open()">Need help?</button>Tell it who the visitor is
HTML
<script>
// After the visitor logs in on your site:
Techvea.identify({
id: "cust_42",
name: "Maria Lopez",
email: "maria@example.com",
attributes: { plan: "pro", country: "ES" } // up to 10 short values
});
</script>Typed by your page, so not verified
Whatever you pass in is shown to the AI as "the website says", and saved with the chat. Do not send passwords, card numbers or anything secret. For account actions that must be certain, use a custom action that checks the customer on your own server.
Send events, and listen to them
JavaScript
Techvea.track("viewed_pricing", { page: "/pricing" });
Techvea.track("cart_value", { total: "129.00" });JavaScript
Techvea.on("open", () => analytics.track("chat_opened"));
Techvea.on("message", () => analytics.track("bot_answered"));
Techvea.on("handoff", () => analytics.track("chat_needs_person"));
Techvea.on("lead", () => analytics.track("chat_lead"));
// the same events also arrive as window events: window.addEventListener("techvea:open", ...)Calling it before the chat has loaded
HTML
<script>
// Calls made before the chat has loaded are kept and run when it is ready:
window.Techvea = window.Techvea || function () { (window.Techvea.q = window.Techvea.q || []).push([].slice.call(arguments)); };
Techvea("identify", { email: "maria@example.com" });
Techvea("open");
</script>
<script src="https://techvea.com/widget.js" data-widget-id="YOUR_WIDGET_ID" async></script>