Skip to contents

ExperimentalVibe Coding

A floating chatbot for Shiny, because apparently the universe decided every app needs to talk back.

Python has chat widgets. JavaScript has chat widgets. R/Shiny had textInput() and optimism.

chatbotr adds a floating chat bubble or slide-out panel to any Shiny app using {shinychat}, with any LLM you connect through {ellmer}. Bring your own key, your own model, and your own judgement.

Installation

pak::pak("freestatman/chatbotr")

[!IMPORTANT] Requires ellmer >= 0.4.0.9000, to use GitHub API as model provider: unreleased PR pak also resolves the shinychat remote (posit-dev/shinychat) so you don’t have to think about it.

Quick start

library(shiny); library(bslib); library(chatbotr)

ui <- page_fluid(
  floating_chat_ui("chat")
)
server <- function(input, output, session) {
  floating_chat_server("chat", client = ellmer::chat_github(model = "gpt-5-mini"))
}
shinyApp(ui, server)

Chat bubble in the bottom-right corner. Click, talk, close. Dashboard stays mercifully intact.

Two flavors

Style UI Server
Floating bubble floating_chat_ui() floating_chat_server()
Slide-out panel offcanvas_chat_ui() offcanvas_chat_server()

Both accept any ellmer client. GitHub Models, OpenAI, Anthropic, Gemini — choose your fighter.

BYOK

Let users supply their own API key at runtime, so you do not become the help desk:

ui <- page_fluid(
  api_settings_ui("settings"),
  floating_chat_ui("chat")
)
server <- function(input, output, session) {
  settings <- api_settings_server("settings")
  observe({
    req(settings$is_configured())
    floating_chat_server("chat", client = settings$client())
  })
}
shinyApp(ui, server)

Or set OPENAI_API_KEY in .Renviron and pretend secrets management was always this simple.

Examples

shiny::runApp(system.file("examples/floating_chat_demo.R", package = "chatbotr"))
shiny::runApp(system.file("examples/byok_floating_chat.R", package = "chatbotr"))
shiny::runApp(system.file("examples/offcanvas_chat_demo.R", package = "chatbotr"))

Browse the example source on GitHub: Floating, BYOK, Offcanvas.

Development

make dev    # format + document + load_all
make test   # unit tests
make check  # R CMD check
make run    # run demo app

Origin story

Vibe-coded across multiple AI editors — opencode, Copilot CLI, Antigravity. A collaborative effort in the ancient tradition of “who wrote this?”

See also

  • ellmer — talk to LLMs from R without hand-rolling everything
  • shinychat — chat UI primitives, which we politely stand on
  • bslib — Bootstrap for Shiny, because plain UI is a cry for help

License

MIT