How To: Write Your First Dialog ๐ก BETA
Tutorial 5 of the BASIC Dialogs Series
Create a simple conversation script in 20 minutes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ ๐ WRITE YOUR FIRST DIALOG โ โ
โ โ โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ
โ โ โ Step โโโโโถโ Step โโโโโถโ Step โโโโโถโ Step โ โ โ
โ โ โ 1 โ โ 2 โ โ 3 โ โ 4 โ โ โ
โ โ โ Create โ โ Write โ โ Test โ โ Enhance โ โ โ
โ โ โ File โ โ Code โ โ Dialog โ โ Logic โ โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Objective
By the end of this tutorial, you will have:
- Created a
.basdialog file - Written code using TALK and HEAR keywords
- Used conditional logic (IF/THEN/ELSE)
- Stored and retrieved user information
- Tested your dialog in the chat interface
Time Required
โฑ๏ธ 20 minutes
Prerequisites
Before you begin, make sure you have:
- A working bot (see Create Your First Bot)
- Access to the Designer or Drive app
- Basic understanding of the chat interface
What is a Dialog?
A dialog is a conversation script written in BASIC that controls how your bot talks with users. Think of it like a script for a play โ you write what the bot should say and how it should respond to the user.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HOW DIALOGS WORK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ User says: "Hello" โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ Dialog Script โ โโโ Your BASIC code runs here โ
โ โ (greeting.bas) โ โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ Bot says: "Hi there! What's your name?" โ
โ โ โ
โ โผ โ
โ User says: "Sarah" โ
โ โ โ
โ โผ โ
โ Bot says: "Nice to meet you, Sarah!" โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Step 1: Create the Dialog File
1.1 Open the Drive App
Click the Apps Menu (โฎโฎโฎ) and select Drive.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Drive โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ๐ mycompany.gbai โ
โ โโโ ๐ mycompany.gbdialog โโโ Dialog files go here โ
โ โโโ ๐ mycompany.gbot โ
โ โโโ ๐ mycompany.gbkb โ
โ โโโ ๐ mycompany.gbdrive โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1.2 Navigate to the Dialog Folder
Double-click mycompany.gbai, then mycompany.gbdialog.
1.3 Create a New File
Click New File (or press Ctrl+N) and name it:
greeting.bas
โ ๏ธ Warning: The file must end with .bas to be recognized as a dialog.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ New File [ร] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ File Name: โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ greeting.bas โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Location: mycompany.gbai / mycompany.gbdialog / โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ Cancel โ โ Create โโโบ โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Checkpoint: You should see greeting.bas in your dialog folder.
Step 2: Write the Dialog Code
2.1 Open the File for Editing
Double-click greeting.bas to open it in the editor.
2.2 Write Your First Line
Type the following code:
TALK "Hello! Welcome to our service. ๐"
This is the simplest possible dialog โ the bot just says one thing.
2.3 Add User Input
Now letโs ask for the userโs name:
TALK "Hello! Welcome to our service. ๐"
TALK "What is your name?"
HEAR name
TALK "Nice to meet you, " + name + "!"
Letโs break this down:
| Line | What It Does |
|---|---|
TALK "..." | Bot displays a message |
HEAR name | Bot waits for user input, stores it in name |
"..." + name + "..." | Combines text with the variable |
2.4 The Complete First Dialog
Hereโs your complete greeting.bas:
' ============================================
' GREETING DIALOG
' A friendly welcome conversation
' ============================================
' Greet the user
TALK "Hello! Welcome to our service. ๐"
' Ask for their name
TALK "What is your name?"
HEAR name
' Respond with their name
TALK "Nice to meet you, " + name + "!"
TALK "How can I help you today?"
๐ก Tip: Lines starting with ' are comments โ theyโre ignored by the bot but help you understand the code.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ greeting.bas [Save] โS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ ' ============================================ โ
โ 2 โ ' GREETING DIALOG โ
โ 3 โ ' A friendly welcome conversation โ
โ 4 โ ' ============================================ โ
โ 5 โ โ
โ 6 โ ' Greet the user โ
โ 7 โ TALK "Hello! Welcome to our service. ๐" โ
โ 8 โ โ
โ 9 โ ' Ask for their name โ
โ 10 โ TALK "What is your name?" โ
โ 11 โ HEAR name โ
โ 12 โ โ
โ 13 โ ' Respond with their name โ
โ 14 โ TALK "Nice to meet you, " + name + "!" โ
โ 15 โ TALK "How can I help you today?" โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2.5 Save the File
Press Ctrl+S or click the Save button.
โ Checkpoint: Your dialog file is saved and ready to test.
Step 3: Test Your Dialog
3.1 Open Chat
Click the Apps Menu (โฎโฎโฎ) and select Chat.
3.2 Trigger the Dialog
Type the command to run your dialog:
/greeting
Or simply type something that matches โgreetingโ โ the system will recognize it.
3.3 Have the Conversation
Watch your dialog run:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฌ Chat โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ค You โ โ
โ โ /greeting โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ค Bot โ โ
โ โ Hello! Welcome to our service. ๐ โ โ
โ โ What is your name? โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ค You โ โ
โ โ Sarah โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ค Bot โ โ
โ โ Nice to meet you, Sarah! โ โ
โ โ How can I help you today? โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Type your message... [โ] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Checkpoint: Your dialog runs and responds correctly!
Step 4: Enhance with Logic
Now letโs make our dialog smarter with conditional logic.
4.1 Add Input Validation
Update your dialog to handle different types of input:
' ============================================
' GREETING DIALOG (Enhanced)
' A friendly welcome with input validation
' ============================================
TALK "Hello! Welcome to our service. ๐"
TALK "What is your name?"
HEAR name
' Check if name was provided
IF name = "" THEN
TALK "I didn't catch your name. That's okay!"
name = "friend"
END IF
TALK "Nice to meet you, " + name + "!"
4.2 Add Menu Options
Letโs give the user choices:
' ============================================
' GREETING DIALOG (Full Version)
' Welcome with menu options
' ============================================
TALK "Hello! Welcome to our service. ๐"
TALK "What is your name?"
HEAR name
IF name = "" THEN
name = "friend"
END IF
TALK "Nice to meet you, " + name + "!"
TALK ""
TALK "How can I help you today?"
TALK "1. Learn about our services"
TALK "2. Contact support"
TALK "3. Check my account"
TALK ""
TALK "Please type 1, 2, or 3:"
HEAR choice
SELECT CASE choice
CASE "1"
TALK "Great! We offer AI-powered automation for businesses."
TALK "Would you like to schedule a demo?"
CASE "2"
TALK "I'll connect you with our support team."
TALK "Please describe your issue:"
HEAR issue
TALK "Thank you. A support agent will contact you about: " + issue
CASE "3"
TALK "To check your account, I'll need to verify your identity."
TALK "Please enter your email address:"
HEAR email
TALK "Looking up account for: " + email
CASE ELSE
TALK "I didn't understand that choice."
TALK "Please type 1, 2, or 3 next time."
END SELECT
TALK ""
TALK "Is there anything else I can help with, " + name + "?"
4.3 Understanding SELECT CASE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SELECT CASE EXPLAINED โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ User types: "2" โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ SELECT CASE choice โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ CASE "1" โโโโถ Skip (not matched) โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ CASE "2" โ
โโโโถ EXECUTE! โโโโถ "I'll connect you..." โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ CASE "3" โโโโถ Skip (not checked after match) โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ CASE ELSE โโโโถ Skip (only runs if nothing matched) โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ END SELECT โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Step 5: Remember User Information
5.1 Store User Data
Use SET USER MEMORY to remember information between conversations:
' After getting the name
SET USER MEMORY "name", name
' Later, in another dialog, retrieve it:
savedName = GET USER MEMORY "name"
IF savedName <> "" THEN
TALK "Welcome back, " + savedName + "!"
ELSE
TALK "Hello! I don't think we've met before."
END IF
5.2 Store Bot-Wide Data
Use SET BOT MEMORY for data that applies to all users:
' Store a bot-wide counter
visitorCount = GET BOT MEMORY "visitor_count"
IF visitorCount = "" THEN
visitorCount = 0
END IF
visitorCount = visitorCount + 1
SET BOT MEMORY "visitor_count", visitorCount
TALK "You are visitor number " + visitorCount + " today!"
Complete Example: Support Request Dialog
Hereโs a complete, practical dialog you can use as a template:
' ============================================
' SUPPORT REQUEST DIALOG
' Collects support ticket information
' ============================================
' Check if we know this user
userName = GET USER MEMORY "name"
IF userName = "" THEN
TALK "Hello! I'm here to help you create a support request."
TALK "First, what's your name?"
HEAR userName
SET USER MEMORY "name", userName
ELSE
TALK "Welcome back, " + userName + "!"
END IF
' Get contact information
TALK "What email should we use to contact you?"
HEAR AS email
email
IF email = "" THEN
TALK "I'll need an email to send you updates."
HEAR AS email
email
END IF
' Get issue category
TALK ""
TALK "What type of issue are you experiencing?"
TALK ""
TALK "1. ๐ง Technical problem"
TALK "2. ๐ณ Billing question"
TALK "3. ๐ฆ Order status"
TALK "4. โ General question"
TALK ""
HEAR category
SELECT CASE category
CASE "1"
categoryName = "Technical"
TALK "I'm sorry you're having technical difficulties."
CASE "2"
categoryName = "Billing"
TALK "I can help with billing questions."
CASE "3"
categoryName = "Orders"
TALK "Let me check on your order."
CASE ELSE
categoryName = "General"
TALK "I'll make sure the right team sees this."
END SELECT
' Get description
TALK ""
TALK "Please describe your issue in detail:"
HEAR description
' Get urgency
TALK ""
TALK "How urgent is this?"
TALK "1. ๐ด Critical - I can't work"
TALK "2. ๐ก High - Affecting my work"
TALK "3. ๐ข Normal - When you get a chance"
HEAR urgency
SELECT CASE urgency
CASE "1"
urgencyLevel = "Critical"
CASE "2"
urgencyLevel = "High"
CASE ELSE
urgencyLevel = "Normal"
END SELECT
' Confirm ticket
TALK ""
TALK "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
TALK "๐ SUPPORT REQUEST SUMMARY"
TALK "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
TALK "Name: " + userName
TALK "Email: " + email
TALK "Category: " + categoryName
TALK "Urgency: " + urgencyLevel
TALK "Issue: " + description
TALK "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
TALK ""
TALK "Should I submit this request? (yes/no)"
HEAR confirm
IF confirm = "yes" OR confirm = "Yes" OR confirm = "YES" THEN
' Here you would typically save to a database
' For now, just confirm
TALK "โ
Your support request has been submitted!"
TALK "Ticket ID: SR-" + FORMAT(NOW, "yyyyMMddHHmm")
TALK "You'll receive a confirmation email at " + email
TALK "Our team typically responds within 24 hours."
ELSE
TALK "No problem! Your request was not submitted."
TALK "Feel free to start over when you're ready."
END IF
TALK ""
TALK "Is there anything else I can help with?"
๐ Congratulations!
Youโve written your first dialog! Hereโs what you learned:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โ Created a .bas dialog file โ
โ โ Used TALK to display messages โ
โ โ Used HEAR to get user input โ
โ โ Combined text with variables โ
โ โ Used IF/THEN/ELSE for decisions โ
โ โ Used SELECT CASE for menus โ
โ โ Stored data with SET USER MEMORY โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Troubleshooting
Problem: Dialog doesnโt start
Cause: File name or location is incorrect.
Solution:
- Verify file ends with
.bas - Confirm file is in the
.gbdialogfolder - Check there are no syntax errors
Problem: โUnexpected tokenโ error
Cause: Syntax error in your code.
Solution:
- Check all strings have opening and closing quotes
- Verify IF statements have matching END IF
- Ensure SELECT CASE has END SELECT
Problem: Variable is empty
Cause: User skipped the HEAR prompt.
Solution:
- Add validation:
IF variable = "" THEN - Provide a default value
- Ask again if needed
Problem: Bot doesnโt remember data
Cause: Not using memory keywords correctly.
Solution:
- Use
SET USER MEMORY "key", valueto save - Use
GET USER MEMORY "key"to retrieve - Ensure key names match exactly (case-sensitive)
Quick Reference
Essential Keywords
| Keyword | Purpose | Example |
|---|---|---|
TALK | Display message | TALK "Hello!" |
HEAR | Get user input | HEAR name |
HEAR AS type | Get typed input | HEAR AS email emailVar |
SET | Set variable | SET x = 5 |
IF/THEN/ELSE | Conditional | IF x > 5 THEN ... END IF |
SELECT CASE | Menu choice | SELECT CASE x ... END SELECT |
SET USER MEMORY | Save user data | SET USER MEMORY "key", value |
GET USER MEMORY | Load user data | x = GET USER MEMORY "key" |
SET BOT MEMORY | Save bot data | SET BOT MEMORY "key", value |
GET BOT MEMORY | Load bot data | x = GET BOT MEMORY "key" |
Common Patterns
Greeting with memory:
name = GET USER MEMORY "name"
IF name = "" THEN
TALK "What's your name?"
HEAR name
SET USER MEMORY "name", name
ELSE
TALK "Welcome back, " + name + "!"
END IF
Menu with validation:
TALK "Choose: 1, 2, or 3"
HEAR choice
IF choice < "1" OR choice > "3" THEN
TALK "Invalid choice, using default."
choice = "1"
END IF
Loop for retries:
attempts = 0
valid = FALSE
WHILE valid = FALSE AND attempts < 3
TALK "Enter your email:"
HEAR AS email input
IF input <> "" THEN
valid = TRUE
END IF
attempts = attempts + 1
WEND
Next Steps
| Next Tutorial | What Youโll Learn |
|---|---|
| Store User Information | Advanced memory patterns |
| Call External APIs | Connect to web services |
| Send Automated Messages | Scheduled broadcasts |
Best Practices
- Comment your code โ Use
'for explanations - Validate all input โ Never assume users type correctly
- Provide defaults โ Handle empty responses gracefully
- Use clear prompts โ Tell users exactly what to type
- Confirm important actions โ Ask before submitting forms
- Use spaces in keywords โ
SET BOT MEMORYnotSET_BOT_MEMORY - Test thoroughly โ Try all menu options and edge cases
Tutorial 5 of 30 โข Back to How-To Index โข Next: Store User Information โ