I am trying to add timestamp to every dialog in botpress chat. So far I am able to add this timestamp in bot's dialog, but I need some pointers in adding the same to user's dialog and choice skill.
Screenshot from chat showing timestamp in bot's dialog Custom component
export class InfaText extends React.Component {
message = this.props.text
getTimestamp = () => {
let date = new Date();
let options = {
month: "short",
day: "numeric", hour: "2-digit", minute: "2-digit"
};
return date.toLocaleTimeString("en-us", options);
}
render() {
return (<div className="infaTextMain">
<p className="infaTextMessage">{this.message}</p>
<small className="infaTextTimestamp">{this.getTimestamp()}</small>
</div>)
}
}
Note: Botpress v11.9.5
Also, is there a generic way to add a timestamp to all dialogs? Update
I followed exactly as stated by @eff_it
I copied MessageWrapper & MySuperOverride functions to modules\infa-module\src\views\lite\index.jsx
Then added below snippet under overrides of modules\channel-web\src\views\full\index.tsx
file
{
module: 'infa-module',
component: 'MySuperOverride'
}
Still no effect, @eff_it please have a look and suggest is it something that is missing here?
Botpress allows for customization by injecting your self-written code. The two main ways to customize Botpress in this way are by using actions and hooks. Actions are called by the Dialog Manager (in the context of a conversation) to retrieve data, call external services, or implement custom reply logic.
At its core, Botpress is a tool to simplify building chatbots for developers. The platform puts together the boilerplate code and infrastructure you need to get a chatbot up and running and gives a complete dev-friendly platform that ships with all the tools you need to build, deploy, and manage production-grade chatbots in record time.
Botpress can add the public key directly in the botpress.config.json file (on the same line). If you prefer to add the key in a file, remove the property certificate, and Botpress will load the key from data/global/end_users_auth.pub
Botpress validates the token, decrypts the content, and makes it available through event.credentials A backend that will authenticate the user and generate the JWT token
have you tried in BP 12 ? custom components are now much easier to achieve.
You can wrap every messages using the setMessageWrapper
of the botpressWebchat store, but to do so, you will need to use the overrides property when you initialize the webchat with another custom component (that won't render anything but would use the webchat store). Here is an example views/lite/index.jsx
export const MessageWrapper = props => (
<div>
<p style={{ color: 'blue' }}>sent on: {new Date(props.sentOn).toDateString()}</p>
<div style={{ background: 'black', color: 'white' }}>{props.children}</div>
</div>
)
export const MySuperOverride = props => {
props.store.setMessageWrapper({ module: 'yourModule', component: 'MessageWrapper' })
return null
}
Then when you initialize the botpressWebchat you can simply use the overrides api as follows
window.botpressWebChat.init({
overrides: {
before_container: {
module: 'yourModule',
component: 'MySuperOverride'
}
}
})
Refer to the docs, there is more information on custom components and custom modules. Here is the resulting rendering:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With