chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.botpress/
|
||||
bp_modules/
|
||||
node_modules/
|
||||
@@ -0,0 +1,2 @@
|
||||
import { BotDefinition } from '@botpress/sdk'
|
||||
export default new BotDefinition({})
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "@bp-templates/empty-bot",
|
||||
"scripts": {
|
||||
"check:type": "tsc --noEmit"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@botpress/client": "1.47.0",
|
||||
"@botpress/sdk": "6.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.16.4",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as bp from '.botpress'
|
||||
|
||||
const bot = new bp.Bot({
|
||||
actions: {},
|
||||
})
|
||||
|
||||
export default bot
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2022"],
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedParameters": true,
|
||||
"target": "es2017",
|
||||
"paths": { "*": ["./*"] },
|
||||
"outDir": "dist",
|
||||
"checkJs": false,
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"resolveJsonModule": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"include": [".botpress/**/*", "src/**/*", "*.ts", "*.json"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.botpress/
|
||||
bp_modules/
|
||||
node_modules/
|
||||
@@ -0,0 +1,33 @@
|
||||
# Integration Title
|
||||
|
||||
> Describe the integration's purpose.
|
||||
|
||||
## Configuration
|
||||
|
||||
> Explain how to configure your integration and list prerequisites `ex: accounts, etc.`.
|
||||
> You might also want to add configuration details for specific use cases.
|
||||
|
||||
## Usage
|
||||
|
||||
> Explain how to use your integration.
|
||||
> You might also want to include an example if there is a specific use case.
|
||||
|
||||
## Limitations
|
||||
|
||||
> List the known bugs.
|
||||
> List known limits `ex: rate-limiting, payload sizes, etc.`
|
||||
> List unsupported use cases.
|
||||
|
||||
## Changelog
|
||||
|
||||
> If some versions of your integration introduce changes worth mentionning (breaking changes, bug fixes), describe them here. This will help users to know what to expect when updating the integration.
|
||||
|
||||
### Integration publication checklist
|
||||
|
||||
- [ ] The register handler is implemented and validates the configuration.
|
||||
- [ ] Title and descriptions for all schemas are present in `integration.definition.ts`.
|
||||
- [ ] Events store `conversationId`, `userId` and `messageId` when available.
|
||||
- [ ] Implement events & actions that are related to `channels`, `entities`, `user`, `conversations` and `messages`.
|
||||
- [ ] Events related to messages are implemented as messages.
|
||||
- [ ] When an action is required by the bot developer, a `RuntimeError` is thrown with instructions to fix the problem.
|
||||
- [ ] Bot name and bot avatar URL fields are available in the integration configuration.
|
||||
@@ -0,0 +1,8 @@
|
||||
<svg width="241" height="241" viewBox="0 0 241 241" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="241" height="241" rx="34" fill="#AAAAAA"/>
|
||||
<path d="M102 112L130.5 95.5L127.5 86L98 103L102 112Z" fill="white"/>
|
||||
<path d="M133 157.5L98.5 137.5L101 128.5L136 148.5L133 157.5Z" fill="white"/>
|
||||
<path d="M172.014 179.812L155.014 189.672C152.532 191.112 149.468 191.112 146.986 189.672L129.986 179.812C127.519 178.381 126 175.744 126 172.892V152.608C126 149.756 127.519 147.119 129.986 145.688L146.986 135.828C149.468 134.388 152.532 134.388 155.014 135.828L172.014 145.688C174.481 147.119 176 149.756 176 152.608V172.892C176 175.744 174.481 178.381 172.014 179.812Z" fill="white"/>
|
||||
<path d="M103 110.108V130.392C103 133.244 101.481 135.881 99.0137 137.312L98.5698 137.57L83.5 129L92 141.38L82.0137 147.172C79.5316 148.612 76.4684 148.612 73.9863 147.172L56.9863 137.312C54.5188 135.881 53 133.244 53 130.392V110.108C53 107.256 54.5188 104.619 56.9863 103.188L73.9863 93.328C76.4684 91.8883 79.5316 91.8883 82.0137 93.328L99.0137 103.188C101.481 104.619 103 107.256 103 110.108Z" fill="white"/>
|
||||
<path d="M172.014 95.312L155.014 105.172C152.532 106.612 149.468 106.612 146.986 105.172L137.789 99.8376L147.5 85.5L130.425 95.5666L129.986 95.312C127.519 93.8809 126 91.2442 126 88.3918V68.1082C126 65.2558 127.519 62.6191 129.986 61.188L146.986 51.328C149.468 49.8883 152.532 49.8883 155.014 51.328L172.014 61.188C174.481 62.6191 176 65.2558 176 68.1082V88.3918C176 91.2442 174.481 93.8809 172.014 95.312Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,9 @@
|
||||
import { IntegrationDefinition } from '@botpress/sdk'
|
||||
import { integrationName } from './package.json'
|
||||
|
||||
export default new IntegrationDefinition({
|
||||
name: integrationName,
|
||||
version: '0.1.0',
|
||||
readme: 'hub.md',
|
||||
icon: 'icon.svg',
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@bp-templates/empty-integration",
|
||||
"integrationName": "empty-integration",
|
||||
"scripts": {
|
||||
"check:type": "tsc --noEmit"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@botpress/client": "1.47.0",
|
||||
"@botpress/sdk": "6.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.16.4",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import * as bp from '.botpress'
|
||||
|
||||
export default new bp.Integration({
|
||||
register: async () => {
|
||||
/**
|
||||
* This is called when an integration configuration is saved.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
unregister: async () => {
|
||||
/**
|
||||
* This is called when a bot removes the integration.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
actions: {},
|
||||
channels: {},
|
||||
handler: async () => {},
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2022"],
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedParameters": true,
|
||||
"target": "es2017",
|
||||
"paths": { "*": ["./*"] },
|
||||
"outDir": "dist",
|
||||
"checkJs": false,
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"resolveJsonModule": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"include": [".botpress/**/*", "src/**/*", "*.ts", "*.json"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.botpress/
|
||||
bp_modules/
|
||||
node_modules/
|
||||
@@ -0,0 +1,33 @@
|
||||
# Plugin Title
|
||||
|
||||
> Describe the plugin's purpose.
|
||||
|
||||
## Configuration
|
||||
|
||||
> Explain how to configure your plugin and list prerequisites `ex: accounts, etc.`.
|
||||
> You might also want to add configuration details for specific use cases.
|
||||
|
||||
## Usage
|
||||
|
||||
> Explain how to use your plugin.
|
||||
> You might also want to include an example if there is a specific use case.
|
||||
|
||||
## Limitations
|
||||
|
||||
> List the known bugs.
|
||||
> List known limits `ex: rate-limiting, payload sizes, etc.`
|
||||
> List unsupported use cases.
|
||||
|
||||
## Changelog
|
||||
|
||||
> If some versions of your plugin introduce changes worth mentionning (breaking changes, bug fixes), describe them here. This will help users to know what to expect when updating the plugin.
|
||||
|
||||
### Plugin publication checklist
|
||||
|
||||
- [ ] The register handler is implemented and validates the configuration.
|
||||
- [ ] Title and descriptions for all schemas are present in `plugin.definition.ts`.
|
||||
- [ ] Events store `conversationId`, `userId` and `messageId` when available.
|
||||
- [ ] Implement events & actions that are related to `channels`, `entities`, `user`, `conversations` and `messages`.
|
||||
- [ ] Events related to messages are implemented as messages.
|
||||
- [ ] When an action is required by the bot developer, a `RuntimeError` is thrown with instructions to fix the problem.
|
||||
- [ ] Bot name and bot avatar URL fields are available in the plugin configuration.
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "@bp-templates/empty-plugin",
|
||||
"pluginName": "empty-plugin",
|
||||
"scripts": {
|
||||
"check:type": "tsc --noEmit"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@botpress/sdk": "6.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.16.4",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { PluginDefinition } from '@botpress/sdk'
|
||||
import { pluginName } from './package.json'
|
||||
|
||||
export default new PluginDefinition({
|
||||
name: pluginName,
|
||||
version: '0.1.0',
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as bp from '.botpress'
|
||||
|
||||
const plugin = new bp.Plugin({
|
||||
actions: {},
|
||||
})
|
||||
|
||||
export default plugin
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2022"],
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedParameters": true,
|
||||
"target": "es2017",
|
||||
"paths": { "*": ["./*"] },
|
||||
"outDir": "dist",
|
||||
"checkJs": false,
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"resolveJsonModule": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"include": [".botpress/**/*", "src/**/*", "*.ts", "*.json"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.botpress/
|
||||
bp_modules/
|
||||
node_modules/
|
||||
@@ -0,0 +1,43 @@
|
||||
# Hello World
|
||||
|
||||
This integration is a template with a single action.
|
||||
|
||||
> Describe the integration's purpose.
|
||||
|
||||
## Configuration
|
||||
|
||||
This integration does not need a configuration.
|
||||
|
||||
> Explain how to configure your integration and list prerequisites `ex: accounts, etc.`.
|
||||
> You might also want to add configuration details for specific use cases.
|
||||
|
||||
## Usage
|
||||
|
||||
To use, call the action `helloWorld`. This action will greet the user.
|
||||
|
||||
> Explain how to use your integration.
|
||||
> You might also want to include an example if there is a specific use case.
|
||||
|
||||
## Limitations
|
||||
|
||||
The `helloWorld` action has a max name size limit of 2^28 - 16 characters (the max javascript string size).
|
||||
|
||||
> List the known bugs.
|
||||
> List known limits `ex: rate-limiting, payload sizes, etc.`
|
||||
> List unsupported use cases.
|
||||
|
||||
## Changelog
|
||||
|
||||
- 0.1.0: Implemented `helloWorld` action.
|
||||
|
||||
> If some versions of your integration introduce changes worth mentionning (breaking changes, bug fixes), describe them here. This will help users to know what to expect when updating the integration.
|
||||
|
||||
### Integration publication checklist
|
||||
|
||||
- [ ] The register handler is implemented and validates the configuration.
|
||||
- [ ] Title and descriptions for all schemas are present in `integration.definition.ts`.
|
||||
- [ ] Events store `conversationId`, `userId` and `messageId` when available.
|
||||
- [ ] Implement events & actions that are related to `channels`, `entities`, `user`, `conversations` and `messages`.
|
||||
- [ ] Events related to messages are implemented as messages.
|
||||
- [ ] When an action is required by the bot developer, a `RuntimeError` is thrown with instructions to fix the problem.
|
||||
- [ ] Bot name and bot avatar URL fields are available in the integration configuration.
|
||||
@@ -0,0 +1,8 @@
|
||||
<svg width="241" height="241" viewBox="0 0 241 241" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="241" height="241" rx="34" fill="#AAAAAA"/>
|
||||
<path d="M102 112L130.5 95.5L127.5 86L98 103L102 112Z" fill="white"/>
|
||||
<path d="M133 157.5L98.5 137.5L101 128.5L136 148.5L133 157.5Z" fill="white"/>
|
||||
<path d="M172.014 179.812L155.014 189.672C152.532 191.112 149.468 191.112 146.986 189.672L129.986 179.812C127.519 178.381 126 175.744 126 172.892V152.608C126 149.756 127.519 147.119 129.986 145.688L146.986 135.828C149.468 134.388 152.532 134.388 155.014 135.828L172.014 145.688C174.481 147.119 176 149.756 176 152.608V172.892C176 175.744 174.481 178.381 172.014 179.812Z" fill="white"/>
|
||||
<path d="M103 110.108V130.392C103 133.244 101.481 135.881 99.0137 137.312L98.5698 137.57L83.5 129L92 141.38L82.0137 147.172C79.5316 148.612 76.4684 148.612 73.9863 147.172L56.9863 137.312C54.5188 135.881 53 133.244 53 130.392V110.108C53 107.256 54.5188 104.619 56.9863 103.188L73.9863 93.328C76.4684 91.8883 79.5316 91.8883 82.0137 93.328L99.0137 103.188C101.481 104.619 103 107.256 103 110.108Z" fill="white"/>
|
||||
<path d="M172.014 95.312L155.014 105.172C152.532 106.612 149.468 106.612 146.986 105.172L137.789 99.8376L147.5 85.5L130.425 95.5666L129.986 95.312C127.519 93.8809 126 91.2442 126 88.3918V68.1082C126 65.2558 127.519 62.6191 129.986 61.188L146.986 51.328C149.468 49.8883 152.532 49.8883 155.014 51.328L172.014 61.188C174.481 62.6191 176 65.2558 176 68.1082V88.3918C176 91.2442 174.481 93.8809 172.014 95.312Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,25 @@
|
||||
import { z, IntegrationDefinition } from '@botpress/sdk'
|
||||
import { integrationName } from './package.json'
|
||||
|
||||
export default new IntegrationDefinition({
|
||||
name: integrationName,
|
||||
version: '0.1.0',
|
||||
readme: 'hub.md',
|
||||
icon: 'icon.svg',
|
||||
actions: {
|
||||
helloWorld: {
|
||||
title: 'Hello World',
|
||||
description: 'A simple hello world action',
|
||||
input: {
|
||||
schema: z.object({
|
||||
name: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
message: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@bp-templates/hello-world",
|
||||
"integrationName": "hello-world",
|
||||
"scripts": {
|
||||
"check:type": "tsc --noEmit"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@botpress/client": "1.47.0",
|
||||
"@botpress/sdk": "6.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.16.4",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import * as bp from '.botpress'
|
||||
|
||||
export default new bp.Integration({
|
||||
register: async () => {
|
||||
/**
|
||||
* This is called when an integration configuration is saved.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
unregister: async () => {
|
||||
/**
|
||||
* This is called when a bot removes the integration.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
actions: {
|
||||
helloWorld: async (props) => {
|
||||
/**
|
||||
* This is called when a bot calls the action `helloWorld`.
|
||||
*/
|
||||
props.logger.forBot().info('Hello World!') // this log will be visible by the bots that use this integration
|
||||
|
||||
let { name } = props.input
|
||||
name = name || 'World'
|
||||
return { message: `Hello "${name}"! Nice to meet you ;)` }
|
||||
},
|
||||
},
|
||||
channels: {},
|
||||
handler: async () => {},
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2022"],
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedParameters": true,
|
||||
"target": "es2017",
|
||||
"paths": { "*": ["./*"] },
|
||||
"outDir": "dist",
|
||||
"checkJs": false,
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"resolveJsonModule": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"include": [".botpress/**/*", "src/**/*", "*.ts", "*.json"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.botpress/
|
||||
bp_modules/
|
||||
node_modules/
|
||||
@@ -0,0 +1,51 @@
|
||||
# Webhook Message
|
||||
|
||||
This integration serves as a template for receiving events through a webhook and creating messages for them, as well as sending messages through an external API.
|
||||
|
||||
> Describe the integration's purpose.
|
||||
|
||||
## Configuration
|
||||
|
||||
To use this integration, you will need to manually subscribe your integration to an external service webhook.
|
||||
You will also have to provide a webhookUrl configuration to send outgoing messages to.
|
||||
|
||||
> Explain how to configure your integration and list prerequisites `ex: accounts, etc.`.
|
||||
> You might also want to add configuration details for specific use cases.
|
||||
|
||||
## Usage
|
||||
|
||||
Send messages through the `webhook` channel to send them through the external webhookUrl you configured.
|
||||
Receive messages through the integration's incoming webhook handler. Received messages have to contain:
|
||||
|
||||
```typescript
|
||||
userId: string
|
||||
conversationId: string
|
||||
text: string
|
||||
```
|
||||
|
||||
> Explain how to use your integration.
|
||||
> You might also want to include an example if there is a specific use case.
|
||||
|
||||
## Limitations
|
||||
|
||||
Only text messages are supported for outgoing messages.
|
||||
|
||||
> List the known bugs.
|
||||
> List known limits `ex: rate-limiting, payload sizes, etc.`
|
||||
> List unsupported use cases.
|
||||
|
||||
## Changelog
|
||||
|
||||
- 0.1.0: Incoming webhook and outgoing channel.
|
||||
|
||||
> If some versions of your integration introduce changes worth mentionning (breaking changes, bug fixes), describe them here. This will help users to know what to expect when updating the integration.
|
||||
|
||||
### Integration publication checklist
|
||||
|
||||
- [ ] The register handler is implemented and validates the configuration.
|
||||
- [ ] Title and descriptions for all schemas are present in `integration.definition.ts`.
|
||||
- [ ] Events store `conversationId`, `userId` and `messageId` when available.
|
||||
- [ ] Implement events & actions that are related to `channels`, `entities`, `user`, `conversations` and `messages`.
|
||||
- [ ] Events related to messages are implemented as messages.
|
||||
- [ ] When an action is required by the bot developer, a `RuntimeError` is thrown with instructions to fix the problem.
|
||||
- [ ] Bot name and bot avatar URL fields are available in the integration configuration.
|
||||
@@ -0,0 +1,8 @@
|
||||
<svg width="241" height="241" viewBox="0 0 241 241" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="241" height="241" rx="34" fill="#AAAAAA"/>
|
||||
<path d="M102 112L130.5 95.5L127.5 86L98 103L102 112Z" fill="white"/>
|
||||
<path d="M133 157.5L98.5 137.5L101 128.5L136 148.5L133 157.5Z" fill="white"/>
|
||||
<path d="M172.014 179.812L155.014 189.672C152.532 191.112 149.468 191.112 146.986 189.672L129.986 179.812C127.519 178.381 126 175.744 126 172.892V152.608C126 149.756 127.519 147.119 129.986 145.688L146.986 135.828C149.468 134.388 152.532 134.388 155.014 135.828L172.014 145.688C174.481 147.119 176 149.756 176 152.608V172.892C176 175.744 174.481 178.381 172.014 179.812Z" fill="white"/>
|
||||
<path d="M103 110.108V130.392C103 133.244 101.481 135.881 99.0137 137.312L98.5698 137.57L83.5 129L92 141.38L82.0137 147.172C79.5316 148.612 76.4684 148.612 73.9863 147.172L56.9863 137.312C54.5188 135.881 53 133.244 53 130.392V110.108C53 107.256 54.5188 104.619 56.9863 103.188L73.9863 93.328C76.4684 91.8883 79.5316 91.8883 82.0137 93.328L99.0137 103.188C101.481 104.619 103 107.256 103 110.108Z" fill="white"/>
|
||||
<path d="M172.014 95.312L155.014 105.172C152.532 106.612 149.468 106.612 146.986 105.172L137.789 99.8376L147.5 85.5L130.425 95.5666L129.986 95.312C127.519 93.8809 126 91.2442 126 88.3918V68.1082C126 65.2558 127.519 62.6191 129.986 61.188L146.986 51.328C149.468 49.8883 152.532 49.8883 155.014 51.328L172.014 61.188C174.481 62.6191 176 65.2558 176 68.1082V88.3918C176 91.2442 174.481 93.8809 172.014 95.312Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,36 @@
|
||||
import { z, IntegrationDefinition } from '@botpress/sdk'
|
||||
import { integrationName } from './package.json'
|
||||
|
||||
export default new IntegrationDefinition({
|
||||
name: integrationName,
|
||||
version: '0.1.0',
|
||||
readme: 'hub.md',
|
||||
icon: 'icon.svg',
|
||||
configuration: {
|
||||
schema: z.object({
|
||||
webhookUrl: z.string().describe('The url to post the bot answers to.'),
|
||||
}),
|
||||
},
|
||||
channels: {
|
||||
webhook: {
|
||||
conversation: {
|
||||
tags: {
|
||||
id: { title: 'Conversation ID', description: 'The ID of the conversation' },
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
// this channel only supports text messages
|
||||
text: {
|
||||
schema: z.object({
|
||||
text: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
user: {
|
||||
tags: {
|
||||
id: { title: 'User ID', description: 'The ID of the user' },
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@bp-templates/webhook-message",
|
||||
"integrationName": "webhook-message",
|
||||
"scripts": {
|
||||
"check:type": "tsc --noEmit"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@botpress/client": "1.47.0",
|
||||
"@botpress/sdk": "6.13.0",
|
||||
"axios": "^1.6.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.16.4",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import axios from 'axios'
|
||||
import * as bp from '.botpress'
|
||||
|
||||
export default new bp.Integration({
|
||||
register: async () => {
|
||||
/**
|
||||
* This is called when an integration configuration is saved.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
unregister: async () => {
|
||||
/**
|
||||
* This is called when a bot removes the integration.
|
||||
* You should use this handler to instanciate ressources in the external service and ensure that the configuration is valid.
|
||||
*/
|
||||
throw new sdk.RuntimeError('Invalid configuration') // replace this with your own validation logic
|
||||
},
|
||||
actions: {},
|
||||
channels: {
|
||||
webhook: {
|
||||
messages: {
|
||||
text: async (props) => {
|
||||
/**
|
||||
* This is the outgoing message handler. It is called when a bot sends a message to the user.
|
||||
*/
|
||||
const {
|
||||
ctx: {
|
||||
configuration: { webhookUrl },
|
||||
},
|
||||
conversation: {
|
||||
id: botpressConversationId,
|
||||
tags: { id: externalConversationId },
|
||||
},
|
||||
payload: { text },
|
||||
} = props
|
||||
|
||||
props.logger.forBot().debug(`[${botpressConversationId}] sending message "${text}"`)
|
||||
|
||||
const requestBody = {
|
||||
conversationId: externalConversationId,
|
||||
text,
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl, requestBody)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
handler: async (props) => {
|
||||
/**
|
||||
* This is the incoming request handler. It is called by the external service you are integrating with.
|
||||
*/
|
||||
const {
|
||||
client,
|
||||
req: { body },
|
||||
} = props
|
||||
|
||||
if (!body) {
|
||||
return {
|
||||
status: 400,
|
||||
body: JSON.stringify({ error: 'No body' }),
|
||||
}
|
||||
}
|
||||
|
||||
let parsedBody: unknown
|
||||
try {
|
||||
parsedBody = JSON.parse(body)
|
||||
} catch {
|
||||
return {
|
||||
status: 400,
|
||||
body: JSON.stringify({ error: 'Invalid JSON Body' }),
|
||||
}
|
||||
}
|
||||
|
||||
const parseResult = sdk.z
|
||||
.object({
|
||||
userId: sdk.z.string(),
|
||||
conversationId: sdk.z.string(),
|
||||
text: sdk.z.string(),
|
||||
})
|
||||
.safeParse(parsedBody)
|
||||
|
||||
if (!parseResult.success) {
|
||||
return {
|
||||
status: 400,
|
||||
body: JSON.stringify({ error: 'Invalid body' }),
|
||||
}
|
||||
}
|
||||
|
||||
const { userId, conversationId, text } = parseResult.data
|
||||
|
||||
const { conversation } = await client.getOrCreateConversation({
|
||||
channel: 'webhook',
|
||||
tags: {
|
||||
id: conversationId,
|
||||
},
|
||||
})
|
||||
|
||||
const { user } = await client.getOrCreateUser({
|
||||
tags: {
|
||||
id: userId,
|
||||
},
|
||||
})
|
||||
|
||||
const { message } = await client.createMessage({
|
||||
type: 'text',
|
||||
conversationId: conversation.id,
|
||||
userId: user.id,
|
||||
payload: {
|
||||
text,
|
||||
},
|
||||
tags: {},
|
||||
})
|
||||
|
||||
const response = {
|
||||
message,
|
||||
}
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
body: JSON.stringify(response),
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2022"],
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedParameters": true,
|
||||
"target": "es2017",
|
||||
"paths": { "*": ["./*"] },
|
||||
"outDir": "dist",
|
||||
"checkJs": false,
|
||||
"exactOptionalPropertyTypes": false,
|
||||
"resolveJsonModule": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUnusedLocals": false
|
||||
},
|
||||
"include": [".botpress/**/*", "src/**/*", "*.ts", "*.json"]
|
||||
}
|
||||
Reference in New Issue
Block a user