Botpress Client
Official Botpress HTTP client for TypeScript. Queries the Botpress API.
Installation
npm install --save @botpress/client
yarn add @botpress/client
pnpm add @botpress/client
Usage
import { Client } from '@botpress/client'
type GetBotInput = ClientInputs['getBot']
type GetBotOutput = ClientOutputs['getBot']
const main = async () => {
const token = 'your-token'
const workspaceId = 'your-workspace-id'
const botId = 'your-bot-id'
const client = new Client({ token, workspaceId, botId })
const { bot } = await client.getBot({ id: botId })
console.log('### bot', bot)
const [latestConversation] = await client.list
.conversations({ sortField: 'createdAt', sortDirection: 'desc', integrationName: 'telegram' })
.collect({ limit: 1 })
console.log('### latestConversation', latestConversation)
for await (const message of client.list.messages({ conversationId: latestConversation.id })) {
console.log(`### [${message.userId}]`, message.payload)
}
}
void main()