Add your agent to a Bubble app
Install the Askocto chat widget in a Bubble app with the embed script, pass the signed-in user to the agent and test it before you go live.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
Use this page to put your agent's chat bubble on a Bubble app. The widget loads from a single script, so you add it once and it appears on every page that carries the code.
Before you start
- An agent with the Website widget turned on. See Channels.
- Permission to edit your Bubble app and deploy it.
- Your agent ID, shown in Channels > Website widget > Install.
Add the script
- Open the agent, select Channels > Website widget and choose Install.
- Copy the embed script.
<script src="https://cdn.askocto.co/embed.js" data-agent-id="agt_123" defer></script>
- In your Bubble app, paste the script into the code that loads on every page, in the header.
- Deploy your app.
You should see the chat bubble in the corner of the deployed app.
Recognize signed-in users
If your app has accounts, tell the agent who is chatting so conversations attach to a contact. Call identify once the user is known.
window.askocto.identify({
userId: "usr_4821",
userHash: "HMAC_FROM_YOUR_SERVER",
name: "Dana Reyes",
email: "dana@example.com",
});
The userHash is an HMAC-SHA256 signature of the user ID. Create it on a server you control, never in the page, because it uses the agent's identity secret. Steps are in Identity verification.
Warning: Do not paste the identity secret into your app's page code or its database fields that users can read. Anyone who has it can impersonate your customers.
Test it
- Open your deployed app in a private browser window.
- Open the bubble and ask a question the agent should know.
- In Test > Playground, ask the same question and compare the answers and the sources used. See Playground.
Remove the widget
Delete the script from your app's header and deploy again. The bubble disappears on the next page load.
Troubleshooting
- No bubble appears. Confirm you deployed after adding the script, and check that the agent ID matches.
- The bubble shows on some pages only. The script was added to a single page. Move it to the code that runs everywhere.
- Users are not recognized. Check that
identifyruns after the user signs in and that the hash is made from the sameuserId.