Skip to main content

Getting started with Code Apps

In this tutorial, you will create, deploy, and test your first Code App directly in the DIAL Chat browser interface. You will build a simple echo application that repeats the user's message. No local tools, terminal commands, or Docker setup required — everything happens in the browser.

Prerequisites​

  • Access to a DIAL Chat instance with Code Apps enabled
  • A user role that allows creating Code Apps (contact your administrator if Add app is unavailable)
  • Basic Python knowledge

What you will build​

An echo application that receives a message through DIAL Chat and responds with the same text. The app runs as a platform-managed container — you write the code, and DIAL handles deployment and hosting.

Step 1: Open Application Builder​

  1. In DIAL Chat, navigate to My workspace.
  2. Click Add app and select Code App.

Application Builder for Code Apps

Application Builder opens with a configuration form and a Python code editor.

Use these values for the General Info section:

FieldValue
NameMy Echo App
Version0.0.1
DescriptionSimple app that echoes your message

Step 2: Configure the app​

Before using the code editor, please fill out the configuration form.

Code App configuration form

Leave other fields at their defaults. The full set of configuration fields:

FieldRequiredDescription
NameYesDisplay name for the Code App.
VersionYesVersion string in x.y.z format (numbers and dots only).
IconNoIcon displayed in DIAL Chat and the Catalog.
TopicsNoPre-defined topic tags. Topics and their styles are defined in DIAL Chat Themes.
DescriptionNoShort description shown in DIAL Chat and the Catalog. Add two line breaks for an extended description.
Attachment typesNoAllowed MIME types (e.g., image/png). Enter */* to allow all types.
Max. attachments numberNoMaximum number of attachments accepted. Leave empty for no limit. Enter 0 to disable attachments.
Select folder with source filesYesOpens the built-in Python code editor. Write code from scratch or upload existing source files.
Runtime versionYesPython runtime environment for code execution.
EndpointsYesChat completion endpoint (required). Rate and configuration endpoints are optional.
Environment variablesNoKey-value pairs accessible to the application at runtime.

Step 3: Write the application code​

In the built-in code editor, create a file named app.py with the following content:

# Save this as app.py
import uvicorn

from aidial_sdk import DIALApp
from aidial_sdk.chat_completion import ChatCompletion, Request, Response

# ChatCompletion is an abstract class for applications and model adapters
class EchoApplication(ChatCompletion):
async def chat_completion(self, request: Request, response: Response) -> None:
# Get last message (the newest) from the history
last_user_message = request.messages[-1]

# Generate response with a single choice
with response.create_single_choice() as choice:
# Fill the content of the response with the last user's content
choice.append_content(last_user_message.text())


# DIALApp extends FastAPI to provide a user-friendly interface for routing requests to your applications
app = DIALApp()
app.add_chat_completion("echo", EchoApplication())

# Run built app
if __name__ == "__main__":
uvicorn.run(app, port=5000)

Key elements in this code:

  • ChatCompletion — base class for all DIAL applications. You implement one method: chat_completion.
  • Request — contains the conversation history. request.messages[-1] is the most recent user message.
  • Response — the object you write output to. create_single_choice() opens a response stream with one choice.
  • DIALApp — a FastAPI-based application router. add_chat_completion("echo", ...) registers your handler under the deployment name echo.

Update "Endpoints -> Chat Completion" with:

/openai/deployments/echo/chat/completions

Also, create a file named requirements.txt in the same folder and add dependencies:

aidial-sdk

Click Save and exit to register the app in DIAL.

Verify: The app appears in My workspace with a red status icon (undeployed).

Step 4: Deploy the app​

  1. In My workspace, find your Code App and open its context menu (three dots).
  2. Click Deploy.
  3. Wait for the status icon to change from yellow (deploying) to green (deployed). This may take a few minutes while the platform builds the container.

Deploy a Code App

Verify: The status icon is green, indicating the app is running.

Step 5: Test in DIAL Chat​

  1. Select the deployed Code App in My workspace.
  2. Click Use application to start a new conversation.
  3. Type a message — for example, Hello, DIAL! — and send it.

Verify: The app responds with the exact text you sent: Hello, DIAL!.

Step 6: View logs​

  1. Open the context menu for your deployed Code App.
  2. Click Logs.

Access Code App logs

A pop-up window displays the application logs. You can refresh and download the log file from this window.

Code App logs viewer

Verify: The logs show request activity from your test message.

What you learned​

  • How to create a Code App using Application Builder in DIAL Chat.
  • How to write a DIAL-compatible Python application using the ChatCompletion base class.
  • How to configure, deploy, and test a Code App entirely in the browser.
  • How to access application logs for debugging.

Demo video​

For a visual walkthrough of Code Apps, including a more advanced RAG example, watch the demo video:

Further reading​