Inbox in your own admin panel
Embed the XACUBE live chat inbox in your own admin panel with a frame: your live agents answer visitors inside your site. Node.js example included.
How it works
Your admin page shows the inbox from app.xacube.ir/embed/inbox in a frame. The frame has no login of its own: it asks your page for a short ticket, your page asks your server, and your server gets the ticket from XACUBE with your inbox key. The key never reaches a browser, and your staff never leave your panel.
Set it up
- In your XACUBE panel open Websites, choose your site, open the Keys tab and press Create inbox key. Copy it: it is shown only once.
- Put the key on your server, for example in the
XACUBE_INBOX_KEYenvironment variable. - Add a server route, protected by your own staff login, that fetches a ticket (below).
- Make sure the address of your admin page is listed under the website’s Domains tab. The inbox only opens on the website’s own domains; a copy of the frame on any other site is refused, even with a valid ticket.
- Add the frame and a few lines of script to your admin page (below). If your site sends a Content Security Policy, allow
frame-src https://app.xacube.ir.
Your server (Node.js / Express)
// Express: hands the inbox frame a short ticket. Protect it with YOUR staff login.
app.post('/admin/xacube/inbox-ticket', requireStaff, async (req, res) => {
const r = await fetch('https://app.xacube.ir/api/plugin/inbox-ticket', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.XACUBE_INBOX_KEY}` }
})
if (!r.ok) return res.status(502).json({ error: 'unavailable' })
res.json(await r.json()) // { ticket, workspaceId, userId, sites, freePlan }
})Your admin page
The frame asks again whenever it needs a fresh ticket, so there is nothing to refresh yourself. Use lang=fa or lang=en to choose the language.
<iframe id="xc-inbox" src="https://app.xacube.ir/embed/inbox?lang=en"
allow="autoplay; clipboard-write" style="width:100%;height:80vh;border:0"></iframe>
<script>
const frame = document.getElementById('xc-inbox')
addEventListener('message', async e => {
if (e.origin !== 'https://app.xacube.ir' || e.source !== frame.contentWindow) return
if (e.data?.type !== 'xc:inbox-ticket-request') return
const r = await fetch('/admin/xacube/inbox-ticket', { method: 'POST', credentials: 'same-origin' })
const data = r.ok ? await r.json() : { error: 'unavailable' }
frame.contentWindow.postMessage({ type: 'xc:inbox-ticket', id: e.data.id, ...data }, 'https://app.xacube.ir')
})
</script>A waiting counter for your menu
Your server can ask how many chats are waiting, about once a minute, to show a badge.
POST https://app.xacube.ir/api/plugin/inbox-summary
Authorization: Bearer <your inbox key>
→ { "waiting": 3 }Who it acts as, and how to stop it
The inbox opens as the person who created the key: everyone who can open your admin page reads and answers all conversations under that name, so protect the page with your own login. Remove the key under Keys at any time; the frame stops working at once. If XACUBE answers 401, the key is no longer valid: create a new one.