npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bp-growth/get-botpress-turn-responses

v1.0.1

Published

Send messages to Botpress bots and get turn-by-turn responses with logs

Readme

get-botpress-turn-responses

Test Botpress bots by sending messages and getting turn-by-turn responses with logs.

Note: Your bot must have the webchat integration installed.

Installation

npm install @bp-growth/get-botpress-turn-responses

Usage

import { getChatTurnResponses } from '@bp-growth/get-botpress-turn-responses';

const messages = [
  { type: 'text', payload: { text: 'Hello' } },
  { type: 'text', payload: { text: 'How are you?' } }
];

const result = await getChatTurnResponses(messages, {
  botId: 'your-bot-id',
  token: 'your-token',
  workspaceId: 'your-workspace-id',
  delayBetweenMessages: 1000 // Optional
});

console.log(result.messages); // All messages
console.log(result.logs);     // All logs

API

getChatTurnResponses(messages, options)

Sends messages to a bot and returns responses with logs.

Parameters

  • messages: Array of message objects with type and payload
    • Messages use the types from @botpress/sdk (text, image, audio, video, file, etc.)
  • options: Configuration object
    • botId: Botpress bot ID (required)
    • token: Botpress API token (required)
    • workspaceId: Botpress workspace ID (required)
    • delayBetweenMessages?: Delay in ms between messages (default: 1000)
    • pollInterval?: Polling interval in ms for logs (default: 500)
    • timeout?: Timeout in ms for turn completion (default: 30000)

Returns

  • conversationId: ID of the created conversation
  • userId: ID of the created user
  • messages: Array of all messages in the conversation (user and bot)
  • logs: Array of all logs from the conversation

Message Types

The library supports all message types from @botpress/sdk:

// Text message
{ type: 'text', payload: { text: 'Hello' } }

// Image message
{ type: 'image', payload: { imageUrl: 'https://example.com/image.jpg' } }

// Audio message
{ type: 'audio', payload: { audioUrl: 'https://example.com/audio.mp3' } }

// Video message  
{ type: 'video', payload: { videoUrl: 'https://example.com/video.mp4' } }

// File message
{ type: 'file', payload: { fileUrl: 'https://example.com/file.pdf' } }

// Card message
{ 
  type: 'card', 
  payload: { 
    title: 'Card Title',
    subtitle: 'Card subtitle',
    imageUrl: 'https://example.com/image.jpg',
    actions: []
  } 
}

// Carousel message
{
  type: 'carousel',
  payload: {
    items: [
      { title: 'Item 1', subtitle: 'Description', imageUrl: '...' },
      { title: 'Item 2', subtitle: 'Description', imageUrl: '...' }
    ]
  }
}

// And more...

Turn Completion Detection

The library monitors the bot's logs for "Billed Tokens:" to determine when a conversation turn is complete. This ensures that all bot responses are received before sending the next message.

Example

import { getChatTurnResponses } from '@bp-growth/get-botpress-turn-responses';

async function testBot() {
  const messages = [
    { type: 'text', payload: { text: 'Hello' } },
    { type: 'text', payload: { text: 'I want to buy a hoodie' } },
    { type: 'text', payload: { text: "What's the most expensive one?" } }
  ];

  try {
    const result = await getChatTurnResponses(messages, {
      botId: process.env.BOTPRESS_BOT_ID!,
      token: process.env.BOTPRESS_TOKEN!,
      workspaceId: process.env.BOTPRESS_WORKSPACE_ID!,
      delayBetweenMessages: 1500
    });

    // Process user and bot messages
    result.messages.forEach(msg => {
      if (msg.userId === result.userId) {
        console.log('User:', msg.payload);
      } else {
        console.log('Bot:', msg.payload);
      }
    });

    // Check turn completions in logs
    const turnCompletions = result.logs.filter(log => 
      log.message.includes('Billed Tokens:')
    );
    console.log('Turns completed:', turnCompletions.length);

  } catch (error) {
    console.error('Error:', error);
  }
}

Development

# Install dependencies
pnpm install

# Build the package
pnpm build

# Run in watch mode
pnpm dev

# Run tests
pnpm test

# Run example
pnpm example

# Type checking
pnpm type-check

# Linting
pnpm lint

# Format code
pnpm format

Requirements

  • Node.js >= 18
  • Botpress account with API access
  • Bot ID, Personal Access Token, and Workspace ID from Botpress

License

MIT