chat_id sent by the iframe.
Embed URL
Start with your agent URL and addembed=1.
Listen For Chat IDs
BoostGPT sends apostMessage event whenever an embedded chat id becomes active.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Persist embedded BoostGPT chat sessions with postMessage
chat_id sent by the iframe.
embed=1.
<iframe
id="boostgpt-agent"
src="https://agent.your-domain.com?embed=1"
style="width: 100%; height: 720px; border: 0;"
allow="clipboard-read; clipboard-write; microphone; camera; fullscreen"
></iframe>
https://agent.your-domain.com/<chat_id>?embed=1
postMessage event whenever an embedded chat id becomes active.
window.addEventListener('message', (event) => {
if (event.origin !== 'https://agent.your-domain.com') return;
if (event.data?.type !== 'boostgpt:chat_id') return;
localStorage.setItem('boostgpt_chat_id', event.data.chat_id);
});
{
type: 'boostgpt:chat_id',
chat_id: 'CHAT_UUID',
bot_id: 'BOT_UUID',
embed: true,
widget: false
}
const iframe = document.getElementById('boostgpt-agent');
const chatId = localStorage.getItem('boostgpt_chat_id');
const baseUrl = 'https://agent.your-domain.com';
iframe.src = chatId
? `${baseUrl}/${encodeURIComponent(chatId)}?embed=1`
: `${baseUrl}?embed=1`;
<iframe
id="boostgpt-agent"
style="width: 100%; height: 720px; border: 0;"
allow="clipboard-read; clipboard-write; microphone; camera; fullscreen"
></iframe>
<script>
const baseUrl = 'https://agent.your-domain.com';
const storageKey = 'boostgpt_chat_id';
const iframe = document.getElementById('boostgpt-agent');
const chatId = localStorage.getItem(storageKey);
iframe.src = chatId
? `${baseUrl}/${encodeURIComponent(chatId)}?embed=1`
: `${baseUrl}?embed=1`;
window.addEventListener('message', (event) => {
if (event.origin !== baseUrl) return;
if (event.data?.type !== 'boostgpt:chat_id') return;
localStorage.setItem(storageKey, event.data.chat_id);
});
</script>
const storageKey = `boostgpt_chat_id:${botId}`;
Was this page helpful?