10.51.10 • Published 6 years ago

@botpress/broadcast v10.51.10

Weekly downloads
118
License
AGPL-3.0-only
Repository
github
Last release
6 years ago

@botpress/broadcast

Get started

npm install @botpress/broadcast

The broadcast module should now be available in your bot UI, and the APIs exposed.

Features

Send according to Users timezone

You can decide whether the scheduled time is absolute to the bot's time or to individual users. If no timezone information available for the user, GMT is chosen.

Filtering

You can apply filters to the broadcasts. Filters are small JavaScript functions that will be evaluated before sending the broadcast to a user. The condition is called for every user the broadcast is scheduled to. You can add multiple filter functions and user will be filtered out if at least one of them returns false.

Variables exposed to the filter function:

  • bp botpress instance
  • userId the userId to send the message to
  • platform the platform on which the user is on

The function needs to return a boolean or a Promise of a boolean.

Note: Starting your function with return is optional.

Examples

Send a message only to users on Facebook
"platform === 'facebook'"
Send a message only to subscribed users

Note: Assuming your bot has a subscriptions table that holds userId and platform

// in your bot's index.js

bp.isUserSubscribed = userId => {
  return bp.db.get()
  .then(knex =>
    knex('subscriptions')
    .where({ userId, platform })
    .select('count(*) as count')
    then().get(0).then(({count}) => count > 0)
  )
}
bp.isUserSubscribed(userId)

Roadmap

  • User segmentation

API

GET /api/botpress-broadcast/broadcasts

Returns a list of the scheduled broadcasts.

PUT /api/botpress-broadcast/broadcasts

Schedules a new broadcast.

Body

{
  date: string, // *required*, 'YYYY-MM-DD'
  time: string, // *required*, 'HH:mm'
  timezone: null|int, // null (users timezone), or integer (absolute timezone)
  type: string, // *required*, 'text' or 'javascript'
  content: string // *required*, the text to be sent or the JavaScript code to execute,
  filters: [string] // filtering conditions, JavaScript code
}

Response

"Hello, Human!"

POST /api/botpress-broadcast/broadcasts

Update an existing broadcast. Same as PUT except that id is also necessary. You can't modify a processing broadcast.

DELETE /api/botpress-broadcast/broadcasts/:id

Delete an existing broadcast. You can't delete a processing broadcast.

Community

Pull requests are welcomed! We believe that it takes all of us to create something big and impactful. There's a Slack community where you are welcome to join us, ask any question and even help others.

Get an invite and join us now! 👉https://slack.botpress.io

License

botpress-broadcast is licensed under AGPL-3.0

10.51.10

6 years ago

10.51.9

6 years ago

10.51.8

6 years ago

10.51.7

7 years ago

10.51.6

7 years ago

10.51.5

7 years ago

10.51.4

7 years ago

10.51.3

7 years ago

10.51.2

7 years ago

10.51.1

7 years ago

10.51.0

7 years ago

10.50.0

7 years ago

10.49.0

7 years ago

10.48.5

7 years ago

10.48.4

7 years ago

10.48.3

7 years ago

10.48.2

7 years ago

10.48.1

7 years ago

10.48.0

7 years ago

10.47.1

7 years ago

10.47.0

7 years ago

10.46.5

7 years ago

10.46.4

7 years ago

10.46.3

7 years ago

10.46.2

7 years ago

10.46.1

7 years ago

10.46.0

7 years ago

10.45.0

7 years ago

10.44.2

7 years ago

10.44.1

7 years ago

10.44.0

7 years ago

10.43.0

7 years ago

10.42.0

7 years ago

10.41.1

7 years ago

10.41.0

7 years ago

10.40.0

7 years ago

10.39.0

7 years ago

10.38.0

7 years ago

10.37.1

7 years ago

10.36.1

7 years ago

10.36.0

7 years ago

10.35.1

7 years ago

10.35.0

7 years ago

10.34.0

7 years ago

10.33.2

7 years ago

10.33.1

7 years ago

10.33.0

7 years ago

10.32.0

7 years ago

10.31.0

7 years ago

10.30.0

7 years ago

10.28.0

7 years ago

10.27.1

7 years ago

10.27.0

7 years ago

10.26.0

7 years ago

10.25.2

7 years ago

10.25.1

7 years ago

10.25.0

7 years ago

10.24.4

7 years ago

10.24.3

7 years ago

10.24.2

7 years ago

10.24.1

7 years ago

10.24.0

7 years ago

10.23.0

7 years ago

10.22.4

7 years ago

10.22.3

7 years ago

10.22.2

7 years ago

10.22.1

7 years ago

10.22.0

7 years ago

10.21.0

7 years ago

10.20.1

7 years ago

10.20.0

7 years ago

10.19.0

7 years ago

10.18.0

7 years ago

10.17.3

7 years ago

10.17.2

7 years ago

10.17.1

7 years ago

10.17.0

7 years ago

10.16.1

7 years ago

10.16.0

7 years ago

10.15.0

7 years ago

10.14.2

7 years ago

10.14.1

7 years ago

10.14.0

7 years ago

10.13.4

7 years ago

10.13.3

7 years ago

10.11.2

7 years ago

10.11.1

7 years ago

10.11.0

7 years ago

10.10.0

7 years ago

10.9.4

7 years ago

10.9.3

7 years ago

10.9.2

7 years ago

10.9.1

7 years ago

10.9.0

7 years ago

10.8.0

7 years ago

10.7.0

7 years ago

10.6.2

7 years ago

10.6.1

7 years ago

10.6.0

7 years ago

10.5.0

7 years ago

10.4.0

7 years ago

10.3.1

7 years ago

10.3.0

7 years ago

10.2.3

7 years ago

10.2.1

7 years ago

10.2.0

7 years ago

10.1.0

7 years ago

10.0.12

7 years ago

10.0.11

7 years ago

10.0.10

7 years ago

10.0.4

7 years ago

10.0.3

7 years ago

10.0.2

7 years ago

10.0.1

7 years ago

10.0.0

7 years ago

2.0.11

7 years ago