Iadvize Adapter for Botfuel
In your botfuel project, run :
npm install --save botfuel-module-adapter-iadvize
Create a new config file in the root directory of your project (eg: iadvize-config.js)
module.exports = {
adapter: {
name: 'iadvize',
},
modules: ['botfuel-module-adapter-iadvize'],
};
- Text messages
- Quickreplies
- Transfer (included in this module)
- Close (included in this module)
To transfer to a distribution rule, include a TransferAction
in the messages returned by your view:
const { View, BotTextMessage } = require('botfuel-dialog');
const { TransferAction } = require('botfuel-module-adapter-iadvize');
class TransferView extends View {
render() {
return [
new BotTextMessage('I’m going to transfer you, please wait :)'),
new TransferAction({
botfuelRoutingRules: ['RULE_NAME_1', 'RULE_NAME_2', ...],
// Transfer attempt failure message
failureMessage: 'Sorry, nobody is available right now.',
// Transfer attempt timeout, default 30 seconds
awaitDuration: 20,
}),
];
}
}
With this Adapter the close event is automatically triggered at the end of bot responses and the conversation is closed if no more messages are sent during the time before the close event is triggered by iAdvize.
You can configure 3 options in the config file of your for this event:
- closeWarningDelay is the delay before the warning message will be sent
- closeWarningMessage is the message that warn the user about the closing of the conversation
- closeDelay is the delay after the warning message and before the close event is sent to iAdvize
The closeWarningDelay and the closeDelay are durations in seconds, they have to be numbers, their default values are both 30 seconds
The closeWarningMessage can be either a string or a function that take the closeDelay in parameter so you can easily customize the message displayed.
The configuration of this event is made under the adapter key in the configuration file of the bot:
module.exports = {
adapter: {
name: 'iadvize',
closeWarningDelay: 30,
closeWarningMessage: (delay) => `The conversation will be closed in ${delay} seconds`,
closeDelay: 120,
},
modules: ['botfuel-module-adapter-iadvize'],
};
In this example, the user will receive the message "The conversation will be closed in 120 seconds" after 30 seconds of inactivity, and the conversation will be closed 120 seconds after the warning message if there is still no news messages from the user or the bot.
The CloseAction work the same way as the close event described below, it takes the same parameters as in the bot configuration but in that case you will configure and trigger the close event through a view.
To use it, include a CloseAction
in the messages returned by your view:
const { View, BotTextMessage } = require('botfuel-dialog');
const { CloseAction } = require('botfuel-module-adapter-iadvize');
class TransferView extends View {
render() {
return [
new BotTextMessage('I’m going to close this conversation.'),
new CloseAction({
closeWarningDelay: 10,
closeWarningMessage: (delay) => `The conversation will be closed in ${delay} seconds`,
closeDelay: 10,
}),
];
}
}
In this example, the user will receive the message "The conversation will be closed in 10 seconds" after 10 seconds of inactivity, and the conversation will be closed 10 seconds after the warning message if there is still no news messages from the user or the bot.
- closeWarningDelay: 30 seconds
- closeWarningMessage: "The conversation will be closed in a few seconds"
- closeDelay: 30 seconds
To add a delay before displaying the quick replies message you can add a delay
option to the message
const { View, BotTextMessage, QuickRepliesMessage } = require('botfuel-dialog');
class DelayedQuickRepliesView extends View {
render() {
return [
new BotTextMessage('I’m going to send quick replies with a delay of 500ms.'),
new QuickrepliesMessage(['hello', 'world'], {
delay: 0.5,
}),
];
}
}