Serves the chat widget as a script to embed on your site. It needs no credentials. The widget itself talks to the API through Start widget chat, Send widget chat message and End widget chat, using the public key from its script tag.
Embed#
<script src="https://api.tried.com.au/widget.js" data-public-key="public_key_c6190cdfff21015a05ac4e386d1158ce" async></script>Script tag attributes#
| Attribute | Required | Description |
|---|---|---|
data-public-key |
Yes | The public key. Without it the widget logs Tried widget: data-public-key is missing to the console and does not render. |
data-title |
No | Header text and button label, used only when the widget settings cannot be loaded. Default Chat with us. |
data-color |
No | Button, header and visitor bubble colour, used only when the widget settings cannot be loaded. Default #18181b. |
data-api |
No | API base URL. Default: https://api.tried.com.au. |
data-recaptcha-site-key |
No | reCAPTCHA v3 site key. Default: the site key built into the served script, if any. When there is a site key, the widget loads reCAPTCHA and sends a token with action chat_start when a chat starts. |
What the widget does#
- Loads the chat agent's look with Get widget settings: title, subtitle, colour, corner, placeholder, teaser, suggested replies and pre-chat form.
- Adds a round chat button in the chosen bottom corner, and shows the teaser bubble once per visit when there is one.
- On the first open, shows the pre-chat form when it is on. Then it gets a reCAPTCHA token if it has a site key, calls
POST /public/chat/startwithpublic_key,recaptcha_tokenand the form answers asdynamic_variables, and shows any greeting with the suggested replies under it. - Sends each message (typed or a tapped suggested reply) with
POST /public/chat/{chat_id}/messageand shows the agent's replies. - On
pagehide, ends the chat withnavigator.sendBeacontoPOST /public/chat/{chat_id}/end.
To pass other dynamic_variables, call Start widget chat from your own UI.
Request#
No parameters.
Example request#
curl "https://api.tried.com.au/widget.js"const res = await fetch("https://api.tried.com.au/widget.js");
const script = await res.text();import requests
script = requests.get("https://api.tried.com.au/widget.js").textResponse#
200 OK with Content-Type: application/javascript and Cache-Control: public, max-age=300. The body is the widget script with the API base URL and the reCAPTCHA site key filled in as defaults.
Errors#
| Status | When |
|---|---|
429 |
Per-IP rate limit exceeded. See Rate limits. |
See Errors for the body format.