︎



︎ Contact Support

Add a Chatbot


 



Start by adding this script tag into your Custom HTML:
<script src="https://static.cargo.site/scripts/loader.js" data-name="chatbot"></script>


Then paste the following code in your CSS Editor:
.chat {
    background:white;
    border: 1px solid black;
    display:none;
    position: relative;
    width: 100%;
    flex-direction: column;
    justify-content: space-between;
}

.chat.initialized {
    display: flex;
}

.chat .chat_wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 70%;
}

.chat .chat_interior {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.chat .chat_output {
    flex-grow: 2;
    overflow-y: auto;
    padding: 1rem;
    display:flex;
    flex-direction:column;
}

.chat .input_area {
    border-top:1px solid black;
    flex-shrink: 0;
    line-height: 3.4rem;
    display: flex;
}

.chat input {
    display:block;
    font:inherit;
    height: 100%;
    width: 50%;
    border:0;
    margin:0;
    padding: 0 1rem;
    flex-grow: 1;
}

.input_area .send_button {
    background: white; 
    display:block;
    border-top: none;
    border-right: none;
    border-bottom: none;
    border-left: 1px solid black;
    font:inherit;
    height: 100%;
    padding: 0 1rem;
}

.input_area .send_button:after {
    content: "SEND"
}

.chat .agent.waiting {
    color: transparent;
}

.chat .agent.waiting div {
    background-color: rgba(0,0,0,0);
    display:inline-block;
    margin: 0 .3em 0.1em 0;
    width: .4em;
    height: .4em;
    border-radius: 100%;
}

.chat .agent.waiting div:nth-child(1) {
    animation: pulse 1s linear .2s infinite;
}

.chat .agent.waiting div:nth-child(2) {
    animation: pulse 1s linear .4s infinite;
}

.chat .agent.waiting div:nth-child(3){
    margin-right: 0;
    animation: pulse 1s linear .6s infinite;
}

.chat .agent {
    text-align:left;
    margin-right: auto;
    max-width: 75%;
    padding: 0.45rem 0.75rem .5rem;
    background: #eee;
    display:inline-block;
}

.chat .user {
    text-align:right;
    margin-left: auto;
    max-width: 75%;
    padding: 0.45rem 0.75rem .5rem;
    display: inline-block;
    border: 1px solid #ccc; 
}

.chat .user+.user {
    margin-top: 0.3em;
}

.chat .agent+.agent {
    margin-top: 0.3em;
}

.chat .user+.agent {
    margin-top: 1em;
}

.chat .agent+.user {
    margin-top: 1em;
}
 
.chat_end {
    font-size: 0.8em;
    opacity: 0.5;
    text-align: center;
    margin-top: 2em;
}

.chat .chat_end:after {
    content: "This chat has ended.";
}

.chat .disabled {
    pointer-events:none;
    color: rgba(0, 0, 0, 0.4);
}
 
@keyframes pulse {

 0% {
    background-color: rgba(0,0,0,0);
 }

 50% {
    background-color: rgba(0,0,0,0.3);
 }

 100% {
    background-color: rgba(0,0,0,0);
 }

} 


While editing a Page, open Code View and create a div with the ‘chat’ class:
<div class="chat"></div>

While inside your Admin, this will render a sample chat to allow you to style and design around the chat interface as needed. Close the Admin and visit the Page to see the chatbot in action.

By default, the chat session will start automatically. You can add links inside the Code View to start or stop a chat session:
<a href="#" rel="start_chat">Start Chat</a>
<a href="#" rel="end_chat">End Chat</a>


If you’d like to place the chat inside a draggable “window,” as in the Desert Template, follow the instructions in this article: Make a Draggable Element.




This chatbot is powered by Norbert Landsteiner’s implementation of Joseph Weizenbaum’s famed ELIZA program. You can read more about the chatbot and its history on Landsteiner’s page for Elizabot.js.

If you know what you’re doing, you can set up this chatbot with your own stock of phrases and topics by creating a custom data file. Download the files for Elizabot.js, find 
elizadata.js
and modify it to your liking. You can then host this file through the Cargo Editor: open a page and click on the File icon () in the Images menu to upload it.

Once you’ve uploaded your file, add it into the chat div as a
data-custom-chat-data
attribute:
<div class="chat" data-custom-chat-data="https://files.cargocollective.com/c12345/customdata.js"></div>