botfactory-conversation
v3.5.8
Published
Component to interact with Bot Factory bots from Senior X Platform.
Downloads
129
Maintainers
Readme
BotFactory conversation
Component to interact with Bot Factory bots from Senior X Platform.
This component is started in any website, you only need to create a HTML element and paste de script bellow changing the variables. If needed, change de optional params.
Use as a lib (NPM)
Currently, to use as library format you need a Font Awesome 5 Pro license added to your project.
In this format you will always need to manually update this package on your project. In the package.json file, add
~
before the version number to auto-increment that inside of the same major. Eg.:~3.0.2
Install the production dependency: npm i botfactory-conversation
Add in your HTML:
Use any identifier.
<div id="botfactory-container"></div>
Typescript
import { BotFactoryConversation } from 'botfactory-conversation'
const config = {
appKey: '1at2b34ka56-789012-4616-141515fsa-fb3a315k277f7b',
element: document.getElementById('botfactory-container'),
restUrl: 'https://platform.senior.com.br/t/senior.com.br/bridge/1.0/anonymous/rest/'
}
const BotFactory = (<any>window).BotFactory as BotFactoryConversation
BotFactory.init(config)
Javascript
Example in ES7 syntax. To ES5 use
require()
import { BotFactoryConversation } from 'botfactory-conversation'
const config = {
appKey: '1at2b34ka56-789012-4616-141515fsa-fb3a315k277f7b',
element: document.getElementById('botfactory-container'),
restUrl: 'https://platform.senior.com.br/t/senior.com.br/bridge/1.0/anonymous/rest/'
}
const BotFactory = (<any>window).BotFactory
BotFactory.init(config)
Use from CDN
<script>
;(function (d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0]
if (d.getElementById(id)) {
return
}
js = d.createElement(s)
js.id = id
js.src =
'https://cdn.tecnologia.senior.com.br/platform/botfactory/conversation/production/bundle.js'
fjs.parentNode.insertBefore(js, fjs)
})(document, 'script', 'botfactory-sdk')
;(function () {
window.onload = function () {
window.BotFactory.init({
appKey: '1at2b34ka56-789012-4616-141515fsa-fb3a315k277f7b',
restUrl: 'https://platform.senior.com.br/t/senior.com.br/bridge/1.0/anonymous/rest/',
autoOpen: true
})
}
})()
</script>
Development
To generate and make available a production bundle (bundle.js
), use the following commands:
webpack
node server.js
API
Lifecycle methods
| Method | Description | Declaration |
| --------- | -------------------------------------------------- | ------------------------------- |
| init
| Starts the conversation component | init(config, callback?): void
|
| destroy
| Close and destroy conversation component component | destroy(): void
|
init()
Pass some properties to the conversation component on your page. Inside the script
tag, use:
window.BotFactory.init({
appKey: 'your-app-key',
autoOpen: true,
width: 500,
height: 900
...
});
| Property | Type | Required | Default value | Description |
| ---------------------- | --------------------------------------- | -------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| appKey
| String
| Yes | undefined
| Represents the key from the bot service. |
| restUrl
| String
| Yes | https://platform.senior.com.br/t/senior.com.br/bridge/1.0/anonymous/rest/
| Environment address to use services. Even if there's a fallback value (padrão), it's fundamental to supply that. |
| username
| String
| No | undefined
| A value to identify the user who talks to the bot. |
| autoOpen
| Boolean
| No | false
| If true
, does the conversation box auto open and starts the conversation |
| mode
| 'user'
| 'monitor'
| 'readonly'
| No | user
| Toggle between conversation modes: conversation or monitoring (Monitoring mode is only available to administrators. |
| development
| Boolean
| No | false
| When in development mode, allow termination conversation with a bot, otherwise, it's only available to minimize de conversation box. |
| width
| Number
| No | 400
| Measures in pixels which indicate the width from conversation box. |
| height
| Number
| No | 600
| Measures in pixels which indicate the height from conversation box. |
| fullScreen
| Boolean
| No | false
| Conversation box in full-screen mode. |
| showFullScreenButton
| Boolean
| No | true
| Allow users to toggle between full-screen mode or window. |