Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@botpress/messaging-client

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botpress/messaging-client

An http client to interact with the botpress Messaging Server

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
754
decreased by-24.3%
Maintainers
5
Weekly downloads
 
Created
Source

Botpress Messaging Client

An HTTP client to make requests to the Botpress Messaging Server and receive webhook events using Express

Installation

Requires Node.js 16

yarn add @botpress/messaging-client
npm install @botpress/messaging-client
pnpm add @botpress/messaging-client

Basic Usage

Initialize the client and respond to messages

// ensure your Express app has the json middleware
app.use(express.json())

// initialize client with your credentials
const client = new MessagingClient({
  clientId: 'my-client-id',
  clientToken: 'my-client-token',
  webhookToken: 'my-webhook-token'
})

// listen for webhook events by providing an express router
client.setup(router)

// register callback method for incoming messages and respond to user
client.on('message', async (e) => {
  await client.createMessage(e.conversationId, undefined, { text: `Hello I'm a bot!` })
})

More Events

The Messaging Server also produces these webhook events

client.on('user', async ({ userId }) => {
  console.log(`new user: ${userId}!`)
})

client.on('started', async ({ userId, conversationId, channel }) => {
  console.log(`new conversation started by ${userId} on ${channel} : ${conversationId}!`)
})

client.on('feedback', async ({ userId, conversationId, channel, messageId, feedback }) => {
  console.log(
    `feedback given by ${userId} on ${channel} in convo ${conversationId} on message ${messageId} : ${feedback}!`
  )
})

Keywords

FAQs

Package last updated on 03 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc