-
-
Notifications
You must be signed in to change notification settings - Fork 198
Global Configuration
Guido edited this page Jun 22, 2020
·
8 revisions
It's possible to specify the bot configuration in Node-RED settings.js
by-passing the configuration panel in Node-RED ui.
- Create a bot configuration, for example for Telegram, and enter just the name, for example "My Bot" and leave all other fields blank
- Open
settings.js
in Node-RED home dir (usually~./.node-red
) and locate the keyfunctionGlobalContext
- Add change the code as follows
functionGlobalContext: {
// ...
telegram: {
'My Bot': {
token: '1234567:my-token',
polling: 1000,
parseMode: 'none',
}
}
},
Be sure to use the same name My Bot used in the configuration panel. 4. Restart Node-RED, the system console should confirm that RedBot is using a global configuration (or dump errors if the configuration is invalid) and the configuration panel in the UI should be disabled.
It's possible to store multiple configurations in the key telegram: {}
and for all supported platforms using the right key (for example facebook: {}
)
The Telegram configuration:
Name | Type | Description |
---|---|---|
token | string | The access token from Telegram, is something like 'xxxxx:yyyyyyyyyyyyyyyyyyyyyy'. Required. |
polling | number | Polling interval in milliseconds. Default 1000. |
usernames | string | Comma separated list of chatIds or username that are considered authorized in the chatbot |
logfile | string | Absolute path of the log file for the chatbot |
contextProvider | string | Which context provide to use, must be one of: memory, plain-file, sqlite |
contextParams | object | Params for the context provider |
debug | boolean | Show message debug in console |
Example:
functionGlobalContext: {
// ...
telegram: {
'My Bot': {
token: '1234567:my-token',
polling: 1000,
parseMode: 'none',
contextProvider: 'plain-file',
contextParams: {
path: '/tmp/red-bot-contexts'
},
logfile: '/var/log/red-bot.logs'
}
}
}
The Facebook configuration:
Name | Type | Description |
---|---|---|
token | string | The access token, from the Facebok app page. Required. |
appSecret | string | The app secret, from the Facebok app page. Required. |
verifyToken | string | The verify token to verify the web hook. |
usernames | string | Comma separated list of chatIds or username that are considered authorized in the chatbot |
logfile | string | Absolute path of the log file for the chatbot |
contextProvider | string | Which context provide to use, must be one of: memory, plain-file, sqlite |
contextParams | object | Params for the context provider |
debug | boolean | Show message debug in console |
Example:
functionGlobalContext: {
// ...
facebook: {
'My Bot': {
token: '1234567:my-token',
appSecret: '0987654321',
verifyToken: 'a-string',
contextProvider: 'plain-file',
contextParams: {
path: '/tmp/red-bot-contexts'
},
logfile: '/var/log/red-bot.logs'
}
}
}
The Slack configuration:
Name | Type | Description |
---|---|---|
token | string | The access token. Required. |
botname | string | The botname, see [[Slack node |
usernames | string | Comma separated list of chatIds or username that are considered authorized in the chatbot |
logfile | string | Absolute path of the log file for the chatbot |
contextProvider | string | Which context provide to use, must be one of: memory, plain-file, sqlite |
contextParams | object | Params for the context provider |
debug | boolean | Show message debug in console |
Example:
functionGlobalContext: {
// ...
facebook: {
'My Bot': {
token: '1234567:my-token',
botname: 'guidone_bot',
contextProvider: 'plain-file',
contextParams: {
path: '/tmp/red-bot-contexts'
},
logfile: '/var/log/red-bot.logs'
}
}
}