The Chatbot is available through our CDN as a single JavaScript file or through NPM as a React component package.
<script type="module">
import Chatbox from 'https://cdn.jsdelivr.net/npm/@chaindesk/embeds@latest/dist/chatbox/index.js';
Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
});
</script>
Attributes / Props
<script type="module">
import Chatbox from 'https://cdn.jsdelivr.net/npm/@chaindesk/embeds@latest/dist/chatbox/index.js';
Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
// If provided will create a contact for the user and link it to the conversation
contact: {
firstName: 'John',
lastName: 'Doe',
email: 'customer@email.com',
phoneNumber: '+33612345644',
userId: '42424242',
},
// Provided context will be appended to the Agent system prompt
context: `The user you are talking to is Georges. Start by Greeting him by his name.`,
interface: {
// Override initial messages
initialMessages: [
'Hello John how are you doing today?',
'How can I help you ?',
],
bubbleIconStyle: {
padding: '5px',
},
iconUrl:
'https://raw.githubusercontent.com/Tarikul-Islam-Anik/Animated-Fluent-Emojis/master/Emojis/Smilies/Love%20Letter.png',
primaryColor: '#f0f',
isInitMessagePopupDisabled: true,
}
});
</script>
Extra context that will be appended to the Agent system prompt
Methods
Open Bubble Chatboxconst widget = await Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
})
widget.open()
Close Bubble Chatboxconst widget = await Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
})
widget.close()
const widget = await Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
})
widget.toggle()
const widget = await Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
})
widget.createNewConversation()
const widget = await Chatbox.initBubble({
agentId: 'YOUR_AGENT_ID',
})
widget.update({
interface: {
initialMessages: ['Hello World!'],
},
context: `Now the user name is Gerald. Always start your answer by greeting him by his name.`,
})