Debugging Bot Behavior in Production
Situation: Bot Behaving Differently in Production
Scenario: Bot Already Live
If your bot is already live and you're facing issues with its behavior, follow these steps:
- Export your bot by clicking the Botpress icon.
- Select "Export as" and save the exported file.
- Go to app.botpress.cloud (opens in a new tab) and log in or create an account.
- Create a new bot within the platform.
- Click the Botpress icon and select "Import from file".
- Upload the exported file to the new bot on the platform.
- This will allow you to safely test and debug your bot's behavior.
Using Text as Breakpoints in Logs (Simple)
If regular logs aren't sufficient, you can add Text Cards at different stages of the conversation to isolate problems:
- Insert Text Cards in various parts of the conversation.
- Deploy the bot to production and engage with it.
- Observe where the conversation deviates from the expected behavior using the text cards as indicators.
Using console.log
in Logs (Advanced)
For more detailed debugging, utilize console.log
statements in the logs:
- Access app.botpress.cloud (opens in a new tab) and select your bot.
- Navigate to the "Logs" tab to view your bot's runtime logs.
- To improve readability, add Custom Code Cards.
- Inside the Custom Code Cards, insert
console.log('message')
statements. - Replace
'message'
with relevant information or variables likeworkflow.userName
. - Deploy the bot to production and trigger conversations.
- Check the logs to analyze the flow of the conversation and gather more information about the bot's behavior.