Skip to main content

Documentation Index

Fetch the complete documentation index at: https://howto.paigeme.dev/llms.txt

Use this file to discover all available pages before exploring further.

Every time your bot handles a message, any console.log, console.error, console.warn, or console.info calls in your code are captured as execution logs. You can view these logs from the Paige dashboard to understand exactly what happened during a conversation — which is especially useful when your bot behaves differently than you expected.

View logs from the dashboard

1

Open your project

From the Paige dashboard, select the project you want to inspect.
2

Go to Logs

In the project sidebar, click Logs. The logs panel shows the most recent execution output for your bot.
3

Filter by log level

Use the log level filter to narrow results. You can show all levels or focus on a specific one — for example, filter to error when tracking down a specific failure.

Log levels

Paige captures four log levels, matching the standard browser console methods:
Use console.log() for general debugging information: variable values, which branch of logic ran, or any output that helps you trace execution flow.
console.log("Received message:", message.body);
console.log("User state:", userState);
Use console.error() to record errors. These are shown prominently in the logs panel and are the first place to look when your bot stops responding correctly.
try {
  const result = await fetchData(userId);
} catch (err) {
  console.error("Failed to fetch user data:", err.message);
}
Use console.warn() for situations that aren’t failures but signal something unexpected — for example, a missing optional field or a fallback path being triggered.
if (!user.phoneNumber) {
  console.warn("User record missing phone number, using fallback");
}
Use console.info() for high-level events like a flow completing, a payment being confirmed, or a user reaching a specific step.
console.info("Booking confirmed for user:", userId);

Add useful logging to your bot code

Good logging makes debugging much faster. A few practices that help:
  • Log inputs at the start of a handler — record the incoming message text and any user state you retrieve, so you can see exactly what your code was working with.
  • Log before and after external calls — if your bot calls an API or queries the database, log the request and response so you can spot failures quickly.
  • Log which branch ran — in conditional logic, add a short log to each branch so you can confirm the right path was taken.
  • Include identifiers — log user IDs or conversation IDs alongside messages so you can correlate log entries with specific users.
console.log("Handling message from:", from);
console.log("Current step:", conversationState.step);

const order = await db.orders.findOne({ userId: from });
if (!order) {
  console.warn("No order found for user:", from);
  return reply("We couldn't find your order. Please try again.");
}

console.log("Order found:", order.id, "status:", order.status);

Common error patterns

Unhandled promise rejections

If your bot makes async calls without try/catch, an error in that call will silently fail. Wrap async operations and log the error to surface the cause.

Undefined variables

A TypeError: Cannot read properties of undefined in the logs usually means a database record or API response wasn’t what you expected. Log the value before you access it.

Unexpected message types

Users can send images, voice notes, and reactions — not just text. If your bot only handles text, log the incoming message type so you can see when non-text messages arrive.

Infinite loops or repeated triggers

If the same log entry appears many times in rapid succession, your bot may be re-triggering itself. Check your reply logic for conditions that might cause a loop.
Use Paige Dev while reviewing logs — link your phone, send a test message, and watch the log entries appear. This gives you a direct line between your action and the output.