Built-in variables
Botpress provides several built-in variables that contain useful information about the current state of your bot. You don’t need to create these variables yourself — you can just read them whenever you need them.
Here’s a list of all the built-in variables in Botpress:
Path | Type | Description |
---|---|---|
event.preview | Event | The last message sent by the user. It will be replaced every time there is a new message. |
conversation.SummaryAgent.summary | Agent | Summary of the conversation created by the Summary Agent. It’s an explanation of what happened. |
conversation.SummaryAgent.transcript | Agent | Transcript of the conversation going back a certain amount of turns. |
turn.KnowledgeAgent.answer | Agent | The answer provided by the Knowledge Agent |
turn.KnowledgeAgent.responded | Agent | Wether the Knowledge Agent has responded automatically to a user question. Its value will be true or false |
turn.KnowledgeAgent?.answer?.length | Agent | The amount of characters in the Knowledge answer. Use this in an Expression to check if there is an answer in the KB. Optionally add ! to start of the code in order to check if there was NOT an answer. |
turn.KnowledgeAgent.citations | Agent | A list of citations for the Knowledge answer. |
user.TranslatorAgent.language | Agent | The current user language code in ISO 639-1 format. More about the Translator Agent |
user.TranslatorAgent.language = 'en' | Agent | This code snippet set’s the user language to English. Replace with any language code in the ISO 639-1 format |
event.kb.results.map((a) => a.dsFriendlyName + '\n' + a.content).join('\n\n') | Event | This code snippet returns the raw content that generated the final Knowledge answer. |
event.tags.conversation['whatsapp:userPhone'] | Integration | The user’s phone number on WhatsApp. Includes the international code. |
event.tags.conversation['whatsapp:phoneNumberId'] | Integration | The phone number Id of the bot on WhatsApp. |