Free cookie consent management tool by TermsFeed

Chat Component

On This Page
The capabilities described on this page are included in Appian's advanced and premium capability tiers. Usage limits may apply.

Function

a!chatField( title, helpTooltip, messages, height, shape, saveInto, showWhen, placeholder, showBorder, streamingUuid, streamingSaveInto, backgroundColor )

Creates a chatbot for building conversations powered by AI.

The chat component gives users an interactive way to work with AI and serves as a core building block for designing many types of chat experiences. It includes key user experience features like automatic scrolling and pressing Enter to send a message, while giving you complete control over the conversation's logic and appearance. By default, it uses Appian's chosen language model through the call language model function: a!callLanguageModel. However, it also supports using your preferred AI model.

You control how the chat behaves and looks. This includes managing chat history, setting conversational context, and customizing the style of messages.

Note:  Supports US English text only.

Parameters

Name Keyword Types Description

Title

title

Text

Content to display above the chat. Create using plain text or components and layouts.

Help Tooltip

helpTooltip

Text

Displays a help icon with the specified text as a tooltip. The icon only shows when the title is in plain text.

Messages

messages

Any Type

List of messages that are displayed within the chat. Plain text messages appear with default styling, while component messages (such as card layouts) render directly.

Height

height

Text

Determines the component height. Valid values: "EXTRA_SHORT", "SHORT", "SHORT_PLUS", "MEDIUM", "MEDIUM_PLUS", "TALL", "TALL_PLUS", "EXTRA_TALL", "AUTO" (default).

Shape

shape

Text

Determines the card shape. Valid values: "SQUARED" (default), "SEMI_ROUNDED", "ROUNDED".

Save Into

saveInto

List of Save

One or more variables that are updated when the user sends a message. Use a!save() to save a modified or alternative value to a variable.

Show When

showWhen

Boolean

Determines whether the component is displayed. When false, the component is hidden and not evaluated. The default is true.

Placeholder

placeholder

Text

Text to display in the field when it is empty. Does not display if the field is read only.

Show Border

showBorder

Boolean

Determines whether the component has an outer border. Default: false.

Streaming UUID

streamingUuid

Text

The UUID returned from a!callLanguageModel that links the chatField component to the streaming response.

Streaming Save Into

streamingSaveInto

List of Save

One or more variables updated periodically with the partial streaming response. The saved value is a map with Content, isDone, and Error keys.

Background Color

backgroundColor

Text

Determines the background color. Valid values: any valid hex color (without transparency), "WHITE" (default), "STANDARD", "TRANSPARENT", "CHARCOAL_SCHEME", "NAVY_SCHEME", "PLUM_SCHEME".

Considerations

Keep the following considerations in mind when choosing how to configure the chat component.

  • Using the default call language model function, a!callLanguageModel(), is the simplest option and requires less setup. See the example on the Call Language Model Function page for details.
  • When using your own preferred AI model, make sure your integration handles authentication, request formatting, and error handling.
  • Switching AI model providers may change the behavior or quality of responses. Test your configuration before deploying to production.

Manage chat conversations

You are responsible for managing the state and history of the conversation. This gives you full control over the user experience. Key responsibilities include:

  • Persistent chat history: To create a continuous conversation, you must save the chat history. A common way to do this is to save the list of messages into a record type after each interaction.
  • Conversational awareness: Most AI models are stateless. To ensure the model has context of the ongoing conversation, you must send the relevant chat history along with the user's latest message in each request.
  • Multiple chat threads: You can build an interface that supports multiple, distinct conversations. To do this, create a mechanism (like a list of threads) that allows the user to select a thread, which then populates the messages parameter with the history for that specific conversation.

Using the messages parameter

The messages parameter is highly flexible and allows you to control the appearance of the chat log.

  • Simple text: For a standard chat look, you can provide a simple list of text values. The component will apply default styling.
  • Custom layouts: For a richer experience, you can pass a list of other components, such as a cardLayout or sideBySideLayout. This allows you to:
    • Add custom avatars for the user and the chatbot.
    • Apply rich text formatting to messages.
    • Include interactive elements, such as a button to edit or copy a message.

Limitations

  • No asynchronous streaming: The chat component does not support streaming responses from the AI model in real-time. The full response must be received before it can be displayed in the interface.
  • Expression-based configuration: The chat component must be configured using expression mode. A custom configuration experience in the design view is not currently available.

Use the chat component with your preferred AI model

You can use your preferred AI model by connecting the component to your AI model provider.

Before you start, make sure you have the following:

  • Access to Appian Designer.
  • A connected system for your chosen AI model provider.
  • Permission to create integrations and expression rules.

Follow these steps to connect the chat component to your preferred AI model provider.

  1. Create an integration object that connects to the orchestration layer for your provider.
  2. Create an expression rule that calls the integration you created. The rule should return responses from your provider's language model.
  3. Edit the interface that contains the chat component.
  4. In the saveInto parameter, call the expression rule you created in step 2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
a!localVariables(
  local!chatMessages: {
    "Hello! How can I help you today?"
  },
  local!chatResponse: null,

  a!chatField(
    title: "Chat with Support",
    helpTooltip: "Type your question to start chatting.",
    messages: local!chatMessages,
    height: "MEDIUM",
    shape: "ROUNDED",
    saveInto: {
      a!save(
        local!chatMessages,
        /* step 1: user message */
        append(local!chatMessages, save!value)
      ),
      a!save(
        local!chatResponse,
        /* step 2: call custom expression rule that wraps your provider integration */
        rule!MY_CUSTOM_LLM_RESPONSE(
          userPrompt: save!value
        )
      ),
      a!save(
        local!chatMessages,
        /* step 3: add AI response */
        append(local!chatMessages, local!chatResponse) 
      )
    },
    showWhen: true,
    placeholder: "Type your question to get started",
    showBorder: true
  )
)

Examples

To experiment with these examples, copy and paste the expression into an interface object.

Basic chat interface

This example demonstrates a simple chat setup. It stores the conversation history in a local variable. The a!save() function in the saveInto parameter appends both the user's new message and a placeholder "…" response to the local messages variable, simulating a conversation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
a!localVariables(
  local!chatMessages: {
    "Hello! How can I help you today?"
  },
  local!chatResponse: null,

  a!chatField(
    title: "Chat with Support",
    helpTooltip: "Type your question to start chatting.",
    messages: local!chatMessages,
    height: "MEDIUM",
    shape: "ROUNDED",
    saveInto: {
      a!save(
        local!chatMessages,
        /* user message */
        append(local!chatMessages, save!value)
      ),
      a!save(
        local!chatResponse,
        a!callLanguageModel(
          prompt: "Default Prompt: " & save!value
        )
      ), /* get model response */
      a!save(
        local!chatMessages,
        /* add AI response */
        append(local!chatMessages, local!chatResponse) 
      )
    },
    showWhen: true,
    placeholder: "Type your question to get started",
    showBorder: true
  )
)

Displays the following:

Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to closeimages/automation/basic-chat-component.png

Custom chat interface

You can build a custom chat-style interface by using the cardLayout component to give each message a distinct visual style. A common approach is to store each message as an object with a sender and text field. Then, apply conditional formatting to display different icons and styles depending on the sender.

For a step-by-step implementation, see the recipe Build a Custom Chat Interface.

Example

Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to closeimages/automation/ai-custom-chat-example.png

Feature compatibility

The table below lists this component's compatibility with various features in Appian.
Feature Compatibility Note
Portals Incompatible
Offline Mobile Incompatible
Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Incompatible

Cannot be used to configure a process event node, such as a start event or timer event.

Process Autoscaling Incompatible

Cannot be used in autoscaled processes.

The following recipes include usage of the Chat Component.

Feedback