% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chat.R
\name{chat_greeting}
\alias{chat_greeting}
\title{Create a greeting for a chat UI}
\usage{
chat_greeting(content, dismissible = TRUE)
}
\arguments{
\item{content}{The greeting content. Can be:
\itemize{
\item A string, interpreted as markdown.
\item An \code{\link[htmltools:HTML]{htmltools::HTML()}} object, rendered as raw HTML.
\item An htmltools tag or \code{\link[htmltools:tagList]{htmltools::tagList()}}, including Shiny
inputs/outputs.
\item A generator or promise (only valid when used with \code{chat_set_greeting()}).
}}

\item{dismissible}{Whether the greeting is automatically dismissed when the
user sends a message. Defaults to \code{TRUE}.}
}
\value{
An S3 object of class \code{"chat_greeting"}.
}
\description{
Creates a greeting object for use with \code{\link[=chat_ui]{chat_ui()}} or \code{\link[=chat_set_greeting]{chat_set_greeting()}}.
A greeting is displayed when the chat first loads and is dismissed when the
user sends their first message.
}
\section{Patterns}{


\strong{Non-dismissible greeting} (stays visible after the user sends a message):

\if{html}{\out{<div class="sourceCode r">}}\preformatted{chat_greeting("Please read our [terms of service](https://example.com).", dismissible = FALSE)
}\if{html}{\out{</div>}}

\strong{Greeting with suggestion cards} (clickable chips that fill the input):

\if{html}{\out{<div class="sourceCode r">}}\preformatted{chat_greeting(paste(
  "## Welcome!\\n\\n",
  "Try one of these:\\n\\n",
  '<span class="suggestion">Summarize my data</span>\\n',
  '<span class="suggestion">Create a plot</span>\\n',
  '<span class="suggestion">Explain this code</span>'
))
}\if{html}{\out{</div>}}

\strong{Greeting with HTML tags} (Shiny inputs/outputs):

\if{html}{\out{<div class="sourceCode r">}}\preformatted{chat_greeting(htmltools::tagList(
  htmltools::h2("Welcome!"),
  shiny::selectInput("model", "Choose a model:", c("gpt-4o", "claude-3"))
))
}\if{html}{\out{</div>}}
}

\examples{
\dontshow{if (interactive()) withAutoprint(\{ # examplesIf}
library(shiny)
library(bslib)
library(shinychat)

ui <- page_fillable(
  chat_ui(
    "chat",
    greeting = chat_greeting("## Welcome!\n\nHow can I help you today?")
  )
)

server <- function(input, output, session) {
  observeEvent(input$chat_user_input, {
    response <- paste0("You said: ", input$chat_user_input)
    chat_append("chat", response)
  })
}

shinyApp(ui, server)
\dontshow{\}) # examplesIf}
}
