Server Notifications Failing 12.10.2

Despite assurances that notifications work they seem not to (well not in 12.10 anyway unless I have made a mistake in my code)

I have a notification implementation as below using the sdk reference instruction and the notification object schema. Its the final part of a knex query where I first retrieve the user name (The one starting with a hash) from the hitl_sessions table and store it in a variable called hashName.

      .finally(() => {
        const message = 'A customer named ' + event.state.user.custname + ' with ID ' + hashName+ ' wants to talk to a real agent'
        bp.notifications.create(botId, { level: 'info', botId, message })

Firstly, I was confused as to why we pass botId to the function when its mandatory in the notification object but I thought maybe you wanted to give the user the ability to create a notification in botA and display it in botB.

I had implemented the above code successfully in a bot on 12.5 but when I tried it on 12.10.2 this morning, I got this error:

Tue Jun 30 2020 08:57:52 GMT+0200 (South Africa Standard Time) Launcher (error)  Unhandled Rejection [error, insert into "srv_notifications" ("botId", "created_on", "id", "level", "message", "module_icon", "module_id", "module_name", "redirect_url") values ($1, now(), $2, $3, $4, $5, $6, $7, $8) returning "id", "botId", "level", "message", "module_id", "module_name", "module_icon", "redirect_url", "created_on" - null value in column "id" violates not-null constraint]
error: null value in column "id" violates not-null constraint
    at Connection.parseE (C:\snapshot\build-windows\node_modules\pg\lib\connection.js:601:11)
    at Connection.parseMessage (C:\snapshot\build-windows\node_modules\pg\lib\connection.js:398:19)
    at Socket.<anonymous> (C:\snapshot\build-windows\node_modules\pg\lib\connection.js:120:22)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onread (net.js:635:20)
Tue Jun 30 2020 08:57:52 GMT+0200 (South Africa Standard Time) ActionService (error) (bot: bud-e) An error occurred while executing the action "connectAPI
                             HTTP (post) URL http://localhost:81/api/v1/bots/bud-e/mod/hitl/channel/web/user/0bDvRzlUptG8Gr0RdvjUt/pause
                             Received "Forbidden: User "" doesn't have access to workspace "default""
                             Request failed with status code 403
Error: Request failed with status code 403
    at createError (C:\snapshot\build-windows\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\snapshot\build-windows\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\snapshot\build-windows\node_modules\axios\lib\adapters\http.js:237:11)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I am a total dunce at reading error logs (if anyone could point me to a resource to help me sharpen that skill) so please tell me where I got it wrong. But I am sure that both the username is the email I am using (this bot has no pro license) and the password ********* :laughing: is the correct thing.

I tried the knex query with some code to send an email in the finally clause and it worked fine with the correct hashName being displayed.


Hi @DigiSenseiZim,

I think the core issue is this error right here:

As you are creating a notification, that apparently does not make much sense, since you are not expected to supply an ID. This leads me to ask whether your database for this bot is SQLite or PostgreSQL. Depending on which it is, the sequence values for the auto-incrementing ID are defined differently.

  • SQLite

You will find sequence info in table sqlite_sequence. Select * from sqlite_sequence where name = 'srv_notifications' to find what is (supposed to be) the latest ID, and Select max(ID) from srv_notifications to find the actual latest ID. If there is a discrepancy, update sqlite_sequence accordingly.

  • PostgreSQL

This one, by default, uses a function to auto-increment. Using pgAdmin, you may drill into the database structure to find the srv_notifications table, then click on the ID column and Properties tab. The constraints should look like this:

I looked up the notifications’ code, no changes occurred in the last year, so I expect this is not a programming issue. Hopefully you will be able to resolve with the information provided.

Let us know if you figure it out!


Thanks for the quick response. I am indeed using PostgreSQL. The bot I had done on 12.5 was a POC and I hadn’t changed the database there from SQLite. Only changed it when the client showed interest so as to have a more solid presentation.

I will fiddle around with it more when I get a chance but if the issue is related to the ID I don’t see how I can go around that. So I am going to conclude that server notifications are useless on a postgres database. They are also generally useless as they disappear once clicked. I wont open a pull request for that as I know that you guys generally ignore anything even remotely related to HITL as a rule of thumb but I will let you know if I can craft my own breed of notification.

Thanks for checking for me so quickly you are far too kind

1 Like

it’s possible to get notifications like your video tutorial from Botpress .
i’m using version 12.10 .
I don’t get any notification like this video .
pls help me !
Thank you