Handling Events

Monitor events from the WebSocket to understand how your agent operates:

ws.on('message', (data) => {
  const event = JSON.parse(data);
  
  switch (event.type) {
    case 'started':
      console.log("Session started:", event);
      break;

    case 'action_run':
      console.log("Action in progress:", event);
      break;
      
    case 'thoughts_and_memories':
      console.log("Thoughts and memories:", event);
      break;

    case 'complete':
      console.log("Session complete:", event);
      break;

    case 'error':
      console.error("Error occurred:", event.error);
      break;

    default:
      console.log("Event received:", event);
  }
});

Last updated