Peki Chatbot Integration Guide
This guide explains how to integrate the Peki chatbot into your website using our JavaScript SDK.
Installation
Add the Peki script to your HTML file. There are two integration methods depending on your use case:
Guest User Integration
For anonymous users, add the following script to your HTML:
<script>
window.pekiSettings = {
chatbotId: "YOUR_CHATBOT_ID",
welcomeMessage: "Hello, how can I assist you today?",
popup: false,
buttonPosition: "right",
theme: "light",
};
!(function () {
var script = document.createElement("script");
script.src = "https://script.peki.ai/chatbox";
script.async = true;
document.body.appendChild(script);
})();
</script>
Authenticated User Integration
For logged-in users, use this enhanced script with user information:
<script>
window.pekiSettings = {
chatbotId: "YOUR_CHATBOT_ID",
userId: "unique_user_id",
name: "User Name",
dataDictionary: {
email: "[email protected]",
phone: "+1234567890",
city: "New York",
},
welcomeMessage: "Hello, how can I assist you today?",
popup: false,
buttonPosition: "right",
theme: "light",
};
!(function () {
var script = document.createElement("script");
script.src = "https://script.peki.ai/chatbox";
script.async = true;
document.body.appendChild(script);
})();
</script>
Configuration Options
Required Fields
chatbotId
: Your unique Peki chatbot identifier- For authenticated users:
userId
: Unique identifier for the username
: User's display name
Optional Fields
welcomeMessage
: Custom greeting message shown when the chat openspopup
: Boolean to control if chat opens automaticallytrue
: Chat window opens automaticallyfalse
: Chat remains minimized until clicked (default)
buttonPosition
: Position of the chat button'right'
: Places button on right side (default)'left'
: Places button on left side
theme
: Visual theme of the chat interface'light'
: Light mode (default)'dark'
: Dark mode
dataDictionary
: Object containing additional user informationemail
: User's email addressphone
: User's phone numbercity
: User's city- Can be extended with custom fields
Sample Implementation
Here's a complete HTML example showing the integration:
<!DOCTYPE html>
<html>
<head>
<title>My Website with Peki Chat</title>
</head>
<body>
<h1>Welcome to my website</h1>
<!-- Peki Chat Integration -->
<script>
window.pekiSettings = {
chatbotId: "YOUR_CHATBOT_ID",
userId: "user123",
name: "John Doe",
dataDictionary: {
email: "[email protected]",
phone: "+1234567890",
city: "San Francisco",
},
welcomeMessage: "Hi there! How can I help you today?",
popup: false,
buttonPosition: "right",
theme: "light",
};
!(function () {
var script = document.createElement("script");
script.src = "https://script.peki.ai/chatbox";
script.async = true;
document.body.appendChild(script);
})();
</script>
</body>
</html>
Best Practices
- Always place the script near the end of your
<body>
tag for optimal page loading - Use a unique and consistent
userId
for authenticated users - Provide as much relevant user information in
dataDictionary
as available - Test the integration in both light and dark themes to ensure proper visibility
Troubleshooting
If the chat widget doesn't appear:
- Verify your
chatbotId
is correct - Check browser console for any JavaScript errors
- Ensure the script is properly loaded and not blocked by ad blockers
- Verify all required fields are properly formatted