Terminal Messenger

A simple, colorful terminal-based messenger application written in Go that connects to a remote messaging endpoint with conversation persistence and history management.

Features

  • 🎨 Colorized output - Blue for your input, green for assistant responses
  • ⌨️ Input history - Navigate previous messages with arrow keys
  • 💾 Conversation persistence - Resume previous conversations seamlessly
  • 📝 Full conversation logs - Both user and assistant messages saved with timestamps
  • 🔄 Auto-resume - Lists your 5 most recent conversations on startup
  • 🏷️ Model tracking - Automatically saves and loads the model used per conversation
  • 🚀 Simple and fast - Minimal setup, quick startup

Prerequisites

  • Go 1.16 or higher
  • Internet connection

Installation

  1. Clone or download the project

  2. Install dependencies

    go get github.com/chzyer/readline
    
  3. Build the application (optional)

    go build -o messenger main.go
    

Usage

Starting the application

Using go run:

go run main.go

Or if you built the binary:

./messenger

First time usage

  1. Press 'n' or Enter when asked about continuing a conversation
  2. Enter a model name (or press Enter for "default")
  3. Start chatting with the assistant
  4. Type quit or exit to end the session

Resuming a conversation

  1. When prompted, you'll see your recent conversations:

    Recent conversations:
    1. resp_d2925cd3-d99c-46f6-a70a-05b1453b8d4f (model: gpt-4)
    2. resp_a1234567-89ab-cdef-0123-456789abcdef (model: default)
    
    Continue? (enter number or 'n' for new):
    
  2. Enter the number (1-5) to resume that conversation

  3. The last 10 message exchanges will be displayed

  4. The model name is automatically loaded

  5. Continue chatting from where you left off

Keyboard shortcuts

  • ↑ (Up arrow) - Navigate to previous input
  • ↓ (Down arrow) - Navigate to next input
  • ←/→ (Left/Right arrows) - Move cursor within current input
  • Ctrl+A - Jump to beginning of line
  • Ctrl+E - Jump to end of line
  • Ctrl+C or type quit/exit - Exit application

How It Works

Conversation Files

For each conversation, three files are created in /tmp/:

  1. messenger_{ID}.tmp - Readline history for arrow key navigation (user inputs only)
  2. messenger_{ID}_log.txt - Full conversation log with timestamps (both user and assistant)
  3. messenger_{ID}_meta.txt - Stores the model name for the conversation

Conversation Continuity

  • Each response from the API includes a unique id
  • This ID is sent as previous_response_id in subsequent requests
  • This maintains conversation context across the entire session
  • When resuming, the conversation ID is loaded and context is preserved

API Configuration

The application connects to:

https://router.ivastudio.verint.live/ProxyScript/run/67bca862210071627d32ef12/current/basic_messenger

To change the endpoint, modify the apiURL constant in main.go.

Request format

{
  "input": "your message here",
  "model": "model name",
  "previous_response_id": "previous response ID for context",
  "metadata": {
    "channel": "text"
  }
}

Response format

{
  "id": "response-id",
  "object": "response",
  "created_at": 1234567890,
  "status": "completed",
  "model": "Model Name",
  "output": [
    {
      "type": "message",
      "id": "message-id",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Assistant response here",
          "annotations": []
        }
      ]
    }
  ]
}

Project Structure

.
├── main.go              # Main application file (~160 lines)
├── go.mod               # Go module file
└── README.md            # This file

Troubleshooting

Connection errors

If you encounter connection errors, check:

  • Your internet connection
  • The endpoint URL is accessible
  • Firewall settings aren't blocking the connection

Module errors

If you get "module not found" errors:

go mod tidy

History file permissions

The app creates files in /tmp/. If you encounter permission errors, ensure you have write access to /tmp/.

Cannot find previous conversations

Conversations are stored in /tmp/ which may be cleared on system restart. For permanent storage, modify the file paths in main.go to use a different directory like ~/.messenger/.

Dependencies

License

This project is provided as-is for educational and development purposes.

Contributing

Feel free to submit issues, fork the repository, and create pull requests for any improvements.:> [!WARNING]