Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@botpress/messaging-client

botpress3.2kAGPL-3.01.2.2TypeScript support: included

An http client to interact with the botpress Messaging Server

botpress, messaging, api, channel, messenger, slack, smooch, teams, telegram, twilio, vonage

readme

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}!`
  )
})

changelog

1.2.7 (2022-10-19)

Bug Fixes

  • webchat: remove start conversion button (#541) (9d5b5e5)

Features

  • server: added prometheus metrics to messaging server (#546) (bf7fd94)
  • telegram: allow receiving file/audio/video/image (#543) (ba628dd)

1.2.6 (2022-09-23)

Bug Fixes

  • components: fix dropdown not disappearing after selection (#507) (d3558f6)
  • components: focus composer when single choice btn is clicked (#525) (f467a13)

Features

  • messenger: allow receiving file content elements (#480) (cfab6a1)
  • webchat: added bot info page to webchat (#537) (bff1b2f)
  • webchat: allow to react on message click (#521) (ace6d45)
  • webchat: allow users to subscribe to different webchat events (#522) (d41eb38), closes #523
  • webchat: create conversation from iframe api (#524) (39bc15e)

1.2.5 (2022-07-29)

1.2.4 (2022-07-28)

Bug Fixes

  • components: fix dropdown not disappearing after selection (#507) (d3558f6)

1.2.3 (2022-05-25)

Features

  • messenger: allow receiving file content elements (#480) (cfab6a1)

1.2.2 (2022-04-19)

Bug Fixes

  • shutdown: fix channels not being cleared correctly (#444) (95fde0f)

1.2.1 (2022-04-12)

Features

1.2.0 (2022-04-01)

1.1.8 (2022-03-30)

Bug Fixes

  • distributed: fix locks failing to release (#429) (dc1f159)

Features

1.1.7 (2022-03-25)

Bug Fixes

  • messenger: remove flaky typing off event (#422) (80549c7)

Features

1.1.6 (2022-03-22)

1.1.5 (2022-03-17)

Features

  • components: added location component (#409) (89ea074)

1.1.4 (2022-03-10)

Bug Fixes

  • pkg: revert to 5.2.0 (#404) (58cdf9a)
  • sockets: fix socket unable to send error message crashing server (#402) (b18c779)

1.1.3 (2022-02-18)

Bug Fixes

Features

1.1.2 (2022-02-17)

1.1.1 (2022-02-17)

Bug Fixes

1.1.0 (2022-02-16)

Bug Fixes

  • inject: fix inject script public path (#361) (6736b59)

Features

1.0.7 (2022-02-11)

Bug Fixes

1.0.6 (2022-02-11)

Features

  • channels: remove experimental channels feature flag (#350) (fffaf9b)

1.0.5 (2022-02-09)

Features

  • clients: allow specifying a custom client id (#343) (cd42f30)

1.0.4 (2022-02-07)

1.0.3 (2022-02-04)

Bug Fixes

  • client: strip unknown data received from webhook (#332) (84a4baa)
  • instance: auto start error 404 instead of 500 (#335) (4671560)

Features

1.0.2 (2022-01-28)

Features

1.0.1 (2022-01-27)

Bug Fixes

1.0.0 (2022-01-25)

0.1.23 (2022-01-19)

Bug Fixes

  • server: fix server not closing when spinned (4bd6a6f)

0.1.22 (2022-01-18)

0.1.21 (2022-01-13)

Bug Fixes

  • channels: readd clearing and fix auto start (#297) (8d01733)
  • migration: fix alter table migration not working with sqlite (#290) (2599256)

Features

0.1.20 (2021-12-13)

Bug Fixes

  • channels: read the conversation.started event (#282) (145d4f4)
  • migrations: fix migrations with targets that are out of bounds (#274) (c0e7a50)
  • sync: add lock for provider name (#284) (f92111c)

Features

0.1.19 (2021-11-30)

Bug Fixes

  • monitoring: fix listing outdated errored conduits (#261) (c046dac)

0.1.18 (2021-11-29)

Bug Fixes

Features

0.1.17 (2021-11-05)

Bug Fixes

Features

0.1.16 (2021-10-28)

Bug Fixes

  • client: fix handling of not found errors (#219) (025f290)

Features

  • components: implement ui components package (#208) (a469775), closes #210
  • converse: close collector when the bot has finished processing (#217) (ccb2154)
  • twilio: twilio testing (#221) (877d448)
  • user-tokens: implement user tokens (#203) (c27fb4d)

0.1.15 (2021-10-19)

Bug Fixes

  • channels: fix typing indicators always on (#201) (9015457)
  • client: fix adding custom headers (#212) (b92ca08)
  • repo: typing errors due to unknow error type (#213) (b13114e)

Features

0.1.14 (2021-10-14)

Bug Fixes

  • slack: slack image rendered requires text in title (#188) (53141f1)
  • vonage: fix too many requests when using sandbox (#176) (59982f2)

0.1.13 (2021-09-14)

Features

0.1.12 (2021-09-02)

Bug Fixes

0.1.11 (2021-08-31)

Bug Fixes

  • monitoring: always setup non lazy when spinned (#158) (2b22a68)

0.1.10 (2021-08-24)

Bug Fixes

  • chat: fix crash when replying to null conduit (#156) (4d0542f)
  • instances: fix instance service destroy (#155) (ffeb091)
  • post: log errors as warnings (#154) (edf54c2)

Features

  • migration: implement migration service (#142) (a6fef7c)

0.1.9 (2021-08-23)

Bug Fixes

  • ci_cd: fix changelog generation on release (510040a)
  • ci_cd: fix changelog generation on release (#146) (49e52cc)
  • health: send configure event when created (#144) (58dc686)

Features

  • board: host url field (#145) (cff7316)
  • server: gracefully close websocket connections on server shutdown (#143) (02b1619)
  • webchat: implement basic webchat (#126) (aed8705), closes #135