Botpress Converse API: Events table in database displaying mixed up order of events

The problem only occurs with the Converse API; the Webchat functions correctly.

Upon inspecting the database, it is apparent that the 'createdOn' timestamp for sequentially sent messages is identical, leading to the mixed-up order. For example:

  • User input prompt
  • Message intended to display after user input
  • Subsequent rendering of user input

What's puzzling is that while examining the database, the createdOn value in the event column differs from the one in the createdOn column used for event sorting:

Event Column

//Dropdown Component asking for user input
{""type"":""custom"",""channel"":""api"",""direction"":""outgoing"",""createdOn"":""2021-04-13T12:45:54.924Z""}
//Response meant to follow user input
{""type"":""text"",""channel"":""api"",""direction"":""outgoing"",""createdOn"":""2021-04-13T12:46:02.645Zā€œā€œ}
//User Input
{""type"":""text"",""channel"":""api"",""direction"":""incoming"",""createdOn"":""2021-04-13T12:46:02.420Z""}

CreatedOn Column

//Dropdown Component
2021-04-13 12:45:55.243118+00 
//Message following User Input
2021-04-13 12:46:03.253342+00
//User Input
2021-04-13 12:46:03.253342+00

Is there a solution to this issue to ensure correct ordering?

Answer ā„–1

Preventing this issue in Botpress may not be feasible. The schema for the events table shows that while the CreatedOn is created using Knex, the event column is a JSON value. It's unclear how the event column corresponds to the event.createdOn value or where it is inserted into the database.

I experimented with the Channel-web module out of curiosity and noticed a timestamp discrepancy also occurring with that module.

Sending a Post Request from the Frontend

Initial payload:

curl 'http://localhost:3001/api/v1/bots/weather/mod/channel-web/messages?__ts=1625757442879' 
-H 'Accept: application/json, text/plain, */*' 
-H 'Authorization: Bearer {{BEARER_TOKEN}}' 
--data-raw '{"webSessionId":"/guest#S9UoXB2NuDfySWqgAAAK","conversationId":7,"payload":{"type":"text","text":"hello"}}'

Events Table in the Database

sqlite> sqlite> select event,createdOn from events where botId = 'weather';

I formatted the event data from the column using JQ to make it readable:

jq .createdOn,.payload
"2021-07-08T15:17:22.888Z"
{
  "type": "text",
  "text": "hello"
}

The createdOn Column (not in the event column) displays:

2021-07-08T15:17:23.456Z

Implementing a Trigger on Insertion

If needed, you can set up a trigger for inserted values. This post provides guidance on handling JSON column values, similar to the event column.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue: Customize data based on userAgent

As a newcomer to VUE, I am attempting to dynamically modify the disabled value based on the userAgent in order to display or hide the paymentMethod: data() { return { paymentMothods: [ { name: 'Visa che ...

Create a feature that allows users to view photos similar to the way it

I want to incorporate a Twitter feed on my website that displays images posted. Instead of having the images redirecting users to Twitter when clicked, I would like them to reveal themselves underneath when a link labeled "View Photo" is clicked, and then ...

Customizing the direction of the Stepper component in React.js using Material UI

I'm facing an unusual challenge where I'm attempting to create a stepper component for my application. Everything is working smoothly so far, but I want the stepper to progress from right to left. Here's what I've tried: Installed i18n ...

Tips on retrieving a specified string from within an array of strings

I need help extracting the inner string from this array within a string: '["sgrdalal21"]' Can someone provide guidance on how to accomplish this? ...

How come only the final element is being displayed from an array in JavaScript, rather than all of the elements present

I am facing an issue while attempting to extract specific information from a JSON data and create a new array with key-value pairs. However, instead of getting all the elements, it only returns the last one. Here is my current code snippet: const input = ...

Show a nested array retrieved from JSON in a React component

I need assistance in displaying data from my JSON file, particularly an innested array using map(). The field I want to display as a list is analyzedInstructions, which looks like this: How to prep (from p How to prep /p) Steps: Remove the cauliflower&a ...

Creating transclusion templates in a compiled format

<div overlay config="overlayConfig"> <div class="dismiss-buttons"> <button class="btn btn-default" ng-click="subscriptions()">Save</button> </div> </div> app.directive("Overlay", ["$timeout", "$compile ...

Using Javascript to generate a button that randomly chooses links within the webpage

Looking for help with JavaScript to select a link when a button is clicked on the page? Check out my code and let me know what I'm doing wrong. For the full code, visit: here HTML <!doctype html> <html lang="it" xmlns="http:/ ...

The JavaScript copy function is no longer functioning properly following the update to the href link

I have implemented a function for copying to clipboard as shown below: function CopyToClipboard(containerid) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); ...

The issue of HTML buttons malfunctioning within a label renderer in three.js

I am facing an issue where the HTML button is not working in the label renderer when both WebGLRenderer and LabelRenderer are used simultaneously. This causes various problems such as orbit control not functioning properly, buttons being unclickable, and a ...

Learn how to incorporate tooltips into Vuetify datatable headers for enhanced user experience

Previously, in older versions of Vuetify, it was possible to access the headerCell slot and easily add tooltips. You can refer to https://codepen.io/nueko/pen/dZoXeZ for more details. In the latest version, named slots are used, requiring knowledge of the ...

The search for the view in the directory "/views" was unsuccessful in Express 4.0

I've been working on a project using Express 4.0 and the Express3-handlebars libraries for NodeJS. Below is the setup: app.set('views', path.join(__dirname, 'views/')); app.engine('hbs', hbs({defaultLayout: 'main&a ...

Interacting between React and Express with CKEditor 5: How to send a request

import React, { Component, useState, useEffect } from 'react'; import { CKEditor } from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; import axios from 'axios'; import pa ...

Confused about the concept of an Ajax callback? Let's break it down

I am retrieving data from a file, specifically /notes.html. I am attempting to save the result of the ajax call in a variable, but for some reason it keeps showing up as undefined. However, when I execute the function in chrome developer tools, it displays ...

What could be causing the jQuery to not function on the live website?

I am currently working with asp.net mvc2 and have developed a project featuring impressive slideshows and menus. While everything runs smoothly on my local machine, I encounter issues with jQuery not functioning properly upon publishing and viewing through ...

Retrieve every hour between two specific timestamps

I am attempting to retrieve all dates between two timestamps that fall on a specific day of the week. I have a start date represented by 'start1' and an end date represented by 'end1'. Additionally, I have a list of days with correspon ...

Secure login verification coupled with intuitive navigation features

Just starting out with react native and I've created a UI for a restaurant app. Now I'm working on converting all static components to dynamic ones. My first task is figuring out how to implement login authentication and then navigate to a specif ...

What is the correct way to update the state of an object in ReactJS using Redux?

Hello, I am facing an issue with storing input field values in the state object named 'userInfo'. Here is what my code looks like: <TextField onChange={this.handleUserUsername.bind(this)} value={this.props.userInfo.username} /> ...

Modifying the structure of serialized data

After serializing a JS form, the data looks like this: .....&xx=xxx&otherError=&input=SMS&message=sdfgs&...... Can anyone provide guidance on how to replace the value of message with the content of a textarea before making an ajax cal ...

Converting a ScrollView to a FlatList: A step-by-step guide

Recently, I came across a React Native pure JavaScript wheel picker component that works great. Here is the link where I found it: https://www.npmjs.com/package/react-native-picker-scrollview However, I noticed that the ScrollView used in this component m ...