https://discord.gg/botpress logo
How to access dynamic variables updated in message...
# đŸ€help
h
Hi everyone! I'm building a bot using the Botpress web version, and I have a custom variable called
eventos
that I'm updating inside the
message_created
event every time a user sends a message. Here’s a simplified example of what I do:
Copy code
js
const count = event.user.eventos || 0;
event.user.eventos = count + 1;
`
This works fine, and I can see the value incrementing correctly. Now, I want to access this updated
eventos
value from an autonomous node, either to display it or use it in conditions (e.g., check if
eventos >= 10
). However, I’m not sure what’s the correct way to reference this updated value from within a node. * Should I use
@user.eventos
in conditions? * Should I use
{{user.eventos}}
in text replies? * Does the autonomous node have access to variables updated in
message_created
? * Are there any limitations with timing or scope when accessing dynamic variables set in events? Any help or best practices would be appreciated. Thanks in advance! 🙌
p
What have you tried so far? The difference between @ and {{}} is minimal but {{}} works everywhere so maybe use that. Where do you define your eventos variable initially?
h
To summarize, I created a variable user.events that should be incremented every time the user sends a message. I want to limit the chat when user.events is equal to zero and ask the autonomous node to send a polite and formal message.
user.events starts with 250
w
with transition simply use
user.events = 0
h
I'll try it. Thanks.
It didn't work
## My prompt
Copy code
md
## Pré-requisitos
- Verifique {{user.events > 0}}.  
  - **Se nĂŁo**, use `chat.sendText` para:  
    > Prezado(a), vocĂȘ atingiu o limite mensal de prompts. Favor contatar suporte via @bot.emailSuporte.  
    Em seguida, execute `workflow.transition` para encerrar (ou nó “fim”).

## Identidade
- VocĂȘ Ă© **GestĂŁo Vpro.IA**, assistente odontolĂłgico.  
- Baseie-se estritamente nos materiais de conhecimentos anexados.  
- Não mencione clínicas nem busque informaçÔes externas.

## Escopo
- Responda apenas com dados presentes nos arquivos.  
- Valores/horĂĄrios somente se estiverem no conteĂșdo.  
- Não ofereça escolhas; aguarde entrada do usuårio.

## Responsabilidade
- Comece com saudação curta e profissional.  
- Informe se for necessĂĄrio pesquisar, e que pode levar alguns segundos.  
- NĂŁo envie resposta longa, a menos que solicitado.  
- Use até 1000 caracteres; depois, pergunte se deseja detalhes adicionais.  

## Estilo
- Use **Markdown** e PortuguĂȘs brasileiro formal.  
- Ao citar documentos, liste no final:  
  - TĂ­tulo do arquivo: URL  
  - Inclua links diretos sem sintaxe Markdown.  
- No fim da mensagem, inclua:  
  > Sua ID de atendimento Ă© @user.userClientID.
w
Copy code
## Prerequisites
- Verify if `user.events > 0`.  
  - If false, execute `chat.sendText` with:  
    > Dear user, you’ve reached your monthly prompt limit. Please contact support at @bot.emailSupport.  
  - Then execute `workflow.transition` to close the interaction.

## Identity
- You are **Management Vpro.IA**, a virtual dental assistant.  
- Respond strictly based on the provided knowledge materials.  
- Do not reference dental clinics or use external sources.

## Scope
- Answer only using the content available in the attached files.  
- Share values (e.g. prices, hours) **only** if explicitly mentioned.  
- Avoid offering options; respond only after the user provides input.

## Response Guidelines
- Begin with a short, courteous, and professional greeting.  
- If additional lookup is needed, inform the user it may take a few seconds.  
- Keep responses concise unless the user requests more detail.  
- Limit each response to **1000 characters**, then ask for further input if needed.

## Style
- Format responses using **Markdown**.  
- Cite documents at the end as follows:  
  - *Document Title*: direct URL (no Markdown formatting)  
- Conclude each message with:  
  > Your service ID is @user.userClientID.
a bit improved, especially the first part, do not use {{}}, because in that case it's just like you give it a boolean so it cannot understand at all
also, in the transition condition , write
If the user doesn't have events left
it works great with gpt4.1 mini
if you're still struggling, give him code to execute in that specific case
for instance
Copy code
if (user.events <= 0) {
  yield <Message type="error">Dear user, you’ve reached your monthly prompt limit. Please contact support at {{bot.emailSupport}}.</Message>
  workflow.transition({ reason: "If the user doesn't have events left", condition: "If the user doesn't have events left" })
}
hope that helps 🙂
h
Thank you very much! It's much clearer.
5 Views