FREE landbot.io clone written in native Vanilla JavaScript. Dead simple & no dependencies, just pure joy! Star me on Github: https://github.com/ThibaultJanBeyer/ui-landing-bot
Created
February 20, 2020 15:04
-
-
Save Mirv/b4430c82278e77f49ff829b449f02233 to your computer and use it in GitHub Desktop.
Vanilla JavaScript framework to create conversational bots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Star me on Github: https://github.com/ThibaultJanBeyer/ui-landing-bot --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Star me on Github: https://github.com/ThibaultJanBeyer/ui-landing-bot | |
*/ | |
var uilb = new UILandingBot(document.body); | |
uilb | |
.message({ | |
content: "Hey! ๐", | |
cssClass: "no-icon", | |
delay: 1000 | |
}) | |
.then(ok => | |
uilb.message({ | |
content: | |
"Iโm the friendly bot and Iโm here to make you <strong>feel good</strong>!", | |
delay: 1000 | |
}) | |
) | |
.then(ok => | |
uilb.message({ | |
cssClass: "fill-img no-icon", | |
content: | |
'heyas pretty person', | |
delay: 1000 | |
}) | |
) | |
.then(ok => | |
uilb.message({ | |
content: "How do you feel?", | |
delay: 1000 | |
}) | |
) | |
.then(ok => | |
uilb.action({ | |
type: "button", | |
items: [ | |
{ | |
text: "cat", | |
value: "meow!" | |
}, | |
{ | |
text: "awesome", | |
value: "awesum!" | |
} | |
] | |
}) | |
) | |
.then(ok => | |
uilb.message({ | |
human: true, | |
content: ok | |
}) | |
) | |
.then(ok => | |
uilb.message({ | |
content: 'Feeling good now? Well, check out my <a href="https://github.com/ThibaultJanBeyer/ui-landing-bot">documentation on Github</a> and leave me a Star now ๐๐๐', | |
delay: 1000 | |
}) | |
) | |
.then(ok => | |
uilb.message({ | |
human: true, | |
content: "I love you! ๐", | |
delay: 2000 | |
}) | |
) | |
.catch(error => console.log('error', error)); | |
// Hash format for UILB: message, content, delay | |
// Param is response key of ok | |
// Pointing to a uilb class obj | |
// Which has keys: human, cssclass, content, delay | |
function navMenuGetChild(response_obj) { | |
// need to setup ... | |
// single step, no decisions | |
// single step, button options | |
// retrieveNext grabs the step in process | |
// UILB grabs message, formats and returns promise | |
return uilb.message(retrieveNext()); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://thibaultjanbeyer.github.io/ui-landing-bot/dist/uilb.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Star me on Github: https://github.com/ThibaultJanBeyer/ui-landing-bot | |
*/ | |
html { | |
background: linear-gradient(to bottom right, #00ffba, #00ffde); | |
width: 100%; | |
height: 100%; | |
color: #fff; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://thibaultjanbeyer.github.io/ui-landing-bot/dist/uilb.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment