Skip to main content

Zen.bot API Message Processing Workflow

1. Message Reception

  • Zen.bot receives a message from various channels (Slack, web app, etc.)
  • The message is converted into a consistent format

2. Message Processing

  • The message is appended to the message array based on the message ID
  • If it's a new conversation, a new message array is started

3. Tool Selection

  • The message is sent to the tool_function (LLM)
  • The LLM selects the correct tool and retrieves parameters from the message context

4. User Preferences

  • A call is made to user preferences
  • Missing parameters can be inferred from user preferences
    • Example: "Weather tomorrow" will use the user's default weather location

5. Workflow Execution

  • Tools (functions) are configured using ReactFlow and often have multiple steps
  • The workflow begins execution:
    1. Check for required parameters
    2. If a parameter is missing, the LLM asks the user for input
    3. The API skips tool selection on subsequent runs with the same message
    4. Once all parameters are present, the workflow continues
    5. API calls to third-party services are made as needed

6. Response Generation

  • Data returned from API calls is passed to the LLM
  • The LLM generates a conversational message for the user
  • Advanced apps may include links or generate charts

7. Response Formatting

  • The complete message is converted into the correct format for the channel
    • Slack: Block Kit
    • Web app: Simple HTML
    • etc.

8. Message Delivery

  • The API has different endpoints for each channel:
    • /webapp
    • /slack
    • /msteams
    • /twilio (phone calls)
    • /api (for testing)
  • Channel-specific adjustments are made:
    • Twilio: Visual components are removed
    • API: Responses are streamed for step-by-step testing

This workflow allows Zen.bot to process messages efficiently, handle missing information, and deliver appropriate responses across various communication channels.