@botpress/sdk 3.6.3 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/dist/bot/client/types.d.ts +10 -9
- package/dist/bot/common/generic.d.ts +6 -1
- package/dist/bot/server/types.d.ts +2 -7
- package/dist/consts.d.ts +1 -0
- package/dist/fixtures.d.ts +31 -2
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +4 -4
- package/dist/integration/client/types.d.ts +10 -4
- package/dist/integration/common/generic.d.ts +6 -1
- package/dist/integration/definition/types.d.ts +2 -1
- package/dist/message.d.ts +44 -44
- package/dist/plugin/action-proxy/proxy.d.ts +2 -2
- package/dist/plugin/common/generic.d.ts +6 -1
- package/dist/plugin/common/types.d.ts +6 -0
- package/dist/plugin/implementation.d.ts +2 -7
- package/dist/plugin/server/types.d.ts +3 -8
- package/dist/plugin/state-proxy/index.d.ts +2 -0
- package/dist/plugin/state-proxy/proxy.d.ts +5 -0
- package/dist/plugin/state-proxy/types.d.ts +25 -0
- package/dist/plugin/state-proxy/types.test.d.ts +1 -0
- package/dist/utils/type-utils.d.ts +14 -1
- package/package.json +2 -2
- package/readme.md +1 -48
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Botpress SDK
|
|
2
2
|
|
|
3
|
-
Official Botpress SDK for TypeScript. Made for building bots and integrations as code.
|
|
3
|
+
Official Botpress SDK for TypeScript. Made for building bots, plugins and integrations as code.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -9,50 +9,3 @@ npm install --save @botpress/sdk # for npm
|
|
|
9
9
|
yarn add @botpress/sdk # for yarn
|
|
10
10
|
pnpm add @botpress/sdk # for pnpm
|
|
11
11
|
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
1. First, write your bot in a TypeScript file. For example, `src/index.ts`:
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { Bot, messages } from '@botpress/sdk'
|
|
19
|
-
|
|
20
|
-
const bot = new Bot({})
|
|
21
|
-
|
|
22
|
-
bot.message('', async ({ message, client, ctx }) => {
|
|
23
|
-
log.info('Received message', message)
|
|
24
|
-
|
|
25
|
-
await client.createMessage({
|
|
26
|
-
conversationId: message.conversationId,
|
|
27
|
-
userId: ctx.botId,
|
|
28
|
-
tags: {},
|
|
29
|
-
type: 'text',
|
|
30
|
-
payload: {
|
|
31
|
-
text: `I'm a stub bot. You said: ${message.payload.text}`,
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
console.log('text message sent')
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
export default bot
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
2. Then, you can run it locally:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
bp serve --entry-point ./src/index.ts # using the botpress CLI
|
|
44
|
-
|
|
45
|
-
ts-node -e "import bot from './src'; void bot.serve()" # or using ts-node directly
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
3. Or, you can bundle it and deploy it to Botpress Cloud:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
bp deploy --entry-point ./src/index.ts # using the botpress CLI
|
|
52
|
-
|
|
53
|
-
# or, using esbuild and the Botpress API
|
|
54
|
-
esbuild --bundle --target=es2019 --platform=node --format=cjs --outfile=bundle.js ./src/index.ts
|
|
55
|
-
code=$(cat bundle.js)
|
|
56
|
-
# call the Botpress API using curl or any other HTTP client
|
|
57
|
-
# see https://botpress.com/docs/api/#bot-update-bot
|
|
58
|
-
```
|