forked from botpress/custom-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
61 lines (51 loc) · 2.35 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import * as sdk from 'botpress/sdk'
import api from './api'
// This is called when server is started, usually to set up the database
const onServerStarted = async (bp: typeof sdk) => {}
// At this point, you would likely setup the API route of your module.
const onServerReady = async (bp: typeof sdk) => {
await api(bp)
}
// Every time a bot is created (or enabled), this method will be called with the bot id
const onBotMount = async (bp: typeof sdk, botId: string) => {}
// This is called every time a bot is deleted (or disabled)
const onBotUnmount = async (bp: typeof sdk, botId: string) => {}
// When anything is changed using the flow editor, this is called with the new flow, so you can rename nodes if you reference them
const onFlowChanged = async (bp: typeof sdk, botId: string, flow: sdk.Flow) => {}
/**
* This is where you would include your 'demo-bot' definitions.
* You can copy the content of any existing bot and mark them as "templates", so you can create multiple bots from the same template.
*/
const botTemplates: sdk.BotTemplate[] = [{ id: 'my_bot_demo', name: 'Bot Demo', desc: 'Some description' }]
/**
* Skills allows you to create custom logic and use them easily on the flow editor
* Check this link for more information: https://botpress.com/docs/building-chatbots/developers/custom-modules#skills
*/
const skills: sdk.Skill[] = []
const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onBotMount,
onBotUnmount,
onFlowChanged,
botTemplates,
skills,
definition: {
// This must match the name of your module's folder, and the name in package.json
name: 'starter-module',
/**
* By default we are using the https://blueprintjs.com/docs/#icons. Use the corresponding name
* Otherwise, create an icon in the assets module in the following format studio_${module.menuIcon}
*/
menuIcon: 'flag',
// This is the name of your module which will be displayed in the sidebar
menuText: 'Complete Module',
// When set to `true`, the name and icon of your module won't be displayed in the sidebar
noInterface: false,
// The full name is used in other places, for example when displaying bot templates
fullName: 'Complete Module',
// Not used anywhere, but should be a link to your website or module repository
homepage: 'https://botpress.com'
}
}
export default entryPoint