Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions bots/bugbuster/bot.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,4 @@ export default new sdk.BotDefinition({
githubWebhookSecret: genenv.BUGBUSTER_GITHUB_WEBHOOK_SECRET,
},
})
.addIntegration(slack, {
enabled: true,
// @ts-ignore TODO: fix config
configurationType: 'botToken',
// @ts-ignore TODO: fix config
configuration: {
botToken: genenv.BUGBUSTER_SLACK_BOT_TOKEN,
signingSecret: genenv.BUGBUSTER_SLACK_SIGNING_SECRET,
botName: 'BugBuster',
},
})
.addIntegration(slack)
1 change: 1 addition & 0 deletions integrations/slack/hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ If you prefer to manually configure the integration, you can provide a bot token
- `team:read`: needed to obtain metadata on your team in order to operate on the right instance of your bot.
- `users.profile:read`: needed to retrieve profile information for channel and DM members.
- `users:read`: needed to obtain a list of all members of the workspace and to receive notifications when new members join the workspace.
- `users:read.email`: needed for the `Get User Profile` action.
6. **IMPORTANT:** install your Slack app to your workspace. This is a crucial step to ensure that the bot can send and receive messages. To do this, scroll up to the "OAuth Tokens for Your Workspace" section and click "Install App to Workspace". Follow the on-screen instructions to authorize the app.
7. Scroll up to the "Advanced token security via token rotation " section and click "Opt In" to enable token rotation. Confirm you wish to opt in.
8. Copy the Refresh Token (starts with `xoxe-1-`) or legacy Bot Token (starts with `xoxb-`). You will need it to set up the integration on Botpress. You may need to refresh the page in the Slack API portal to see the token.
Expand Down
2 changes: 1 addition & 1 deletion integrations/slack/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default new IntegrationDefinition({
name: 'slack',
title: 'Slack',
description: 'Automate interactions with your team.',
version: '2.5.4',
version: '2.5.5',
icon: 'icon.svg',
readme: 'hub.md',
configuration,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"@botpress/chat": "0.5.1",
"@botpress/client": "1.20.0",
"@botpress/sdk": "4.15.1",
"@botpress/sdk": "4.15.2",
"@bpinternal/const": "^0.1.0",
"@bpinternal/tunnel": "^0.1.1",
"@bpinternal/yargs-extra": "^0.0.3",
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/command-implementations/project-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ export abstract class ProjectCommand<C extends ProjectCommandDefinition> extends
return {
integrations: _(integrations)
.keyBy((i) => i.id)
.mapValues(
({ enabled, configurationType, configuration, disabledChannels }) =>
({
enabled,
configurationType,
configuration,
disabledChannels,
}) satisfies NonNullable<apiUtils.UpdateBotRequestBody['integrations']>[string]
)
.value(),
plugins: utils.records.mapValues(pluginsWithBackingIntegrations, (plugin) => ({
...plugin,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.20.0",
"@botpress/sdk": "4.15.1"
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.20.0",
"@botpress/sdk": "4.15.1"
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/sdk": "4.15.1"
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.20.0",
"@botpress/sdk": "4.15.1"
"@botpress/sdk": "4.15.2"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/webhook-message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@botpress/client": "1.20.0",
"@botpress/sdk": "4.15.1",
"@botpress/sdk": "4.15.2",
"axios": "^1.6.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/sdk",
"version": "4.15.1",
"version": "4.15.2",
"description": "Botpress SDK",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
150 changes: 150 additions & 0 deletions packages/sdk/src/bot/definition.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { test } from 'vitest'
import { IntegrationConfigInstance, IntegrationInstance } from './definition'
import * as utils from '../utils/type-utils'
import { IntegrationDefinition } from '../integration'
import { z } from '@bpinternal/zui'

test('IntegrationInstance should contain important API fields', async () => {
type Actual = IntegrationInstance
type Expected = {
enabled?: boolean
configurationType?: string | null
configuration?: Record<string, any>
}

type _assertion = utils.AssertExtends<Actual, Expected>
})

test('IntegrationConfigInstance of integration with no config should be empty', async () => {
const def = new IntegrationDefinition({
name: 'frodo',
version: '1.0.0',
})
type Def = typeof def

type Actual = IntegrationConfigInstance<{
type: 'integration'
name: Def['name']
version: Def['version']
definition: Def
implementation: null
}>

type Expected = {
enabled: boolean
disabledChannels?: string[] | undefined
} & (
| {
configurationType?: null
configuration: Record<string, any>
}
| {
configurationType: string
configuration: Record<string, any>
}
)

type _assertion = utils.AssertAll<
[
//
utils.AssertExtends<Actual, Expected>,
utils.AssertExtends<Expected, Actual>,
utils.IsEquivalent<Actual, Expected>,
]
>
})

test('IntegrationConfigInstance of integration with single config schema should only allow the single config schema', async () => {
const def = new IntegrationDefinition({
name: 'frodo',
version: '1.0.0',
configuration: {
schema: z.object({
theOneRing: z.string().describe('The One Ring'),
}),
},
})
type Def = typeof def

type Actual = IntegrationConfigInstance<{
type: 'integration'
name: Def['name']
version: Def['version']
definition: Def
implementation: null
}>

type Expected = {
enabled: boolean
disabledChannels?: string[] | undefined
} & (
| {
configurationType?: null
configuration: { theOneRing: string }
}
| {
configurationType: string
configuration: Record<string, any>
}
)

type _assertion = utils.AssertAll<
[
//
utils.AssertExtends<Actual, Expected>,
utils.AssertExtends<Expected, Actual>,
utils.IsEquivalent<Actual, Expected>,
]
>
})

test('IntegrationConfigInstance of integration with multiple config schemas should allow any of the schemas', async () => {
const def = new IntegrationDefinition({
name: 'frodo',
version: '1.0.0',
configuration: {
schema: z.object({
theOneRing: z.string().describe('The One Ring'),
}),
},
configurations: {
withSword: {
schema: z.object({
sting: z.string().describe('Sting; The sword of Frodo'),
}),
},
},
})
type Def = typeof def

type Actual = IntegrationConfigInstance<{
type: 'integration'
name: Def['name']
version: Def['version']
definition: Def
implementation: null
}>

type Expected = {
enabled: boolean
disabledChannels?: string[] | undefined
} & (
| {
configurationType?: null
configuration: { theOneRing: string }
}
| {
configurationType: 'withSword'
configuration: { sting: string }
}
)

type _assertion = utils.AssertAll<
[
//
utils.AssertExtends<Actual, Expected>,
utils.AssertExtends<Expected, Actual>,
utils.IsEquivalent<Actual, Expected>,
]
>
})
12 changes: 6 additions & 6 deletions packages/sdk/src/bot/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export type PluginConfigInstance<P extends PluginPackage = PluginPackage> = {
}
}

export type IntegrationInstance = IntegrationPackage & IntegrationConfigInstance
export type IntegrationInstance = IntegrationPackage & Partial<IntegrationConfigInstance>
export type PluginInstance = PluginPackage & PluginConfigInstance

export type BotDefinitionProps<
Expand Down Expand Up @@ -199,18 +199,18 @@ export class BotDefinition<
}
}

public addIntegration<I extends IntegrationPackage>(integrationPkg: I, config: IntegrationConfigInstance<I>): this {
public addIntegration<I extends IntegrationPackage>(integrationPkg: I, config?: IntegrationConfigInstance<I>): this {
const self = this as Writable<BotDefinition>
if (!self.integrations) {
self.integrations = {}
}

self.integrations[integrationPkg.name] = {
enabled: config.enabled,
...integrationPkg,
configurationType: config.configurationType,
configuration: config.configuration,
disabledChannels: config.disabledChannels,
enabled: config?.enabled,
configurationType: config?.configurationType,
configuration: config?.configuration,
disabledChannels: config?.disabledChannels,
}
return this
}
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading