CSML Reference
  • Introduction
  • Installing CSML
  • Sending and Receiving Messages
    • Message Payloads
    • Custom Components
  • The Event
  • Memory
    • Using Variables in Messages
    • Temporary and Long-Term variables
    • Global variables
  • Navigating in a CSML Bot
  • Conditional Logic
  • External Code Execution
  • Native CSML Functions
  • Value Types
  • Automatic Type Inference
  • 📑CSML Studio Documentation
  • Standard Library
    • Keywords
    • Built-in Functions
    • HTTP Client
    • SMTP Client
    • Crypto Utilities
      • JWT
      • Hash, HMAC
      • Base64, Hex
    • String methods
    • Array methods
    • Object methods
    • Number methods
    • Generic methods
Powered by GitBook
On this page
  • Standard message components
  • Text()
  • Typing()
  • Wait()
  • Url()
  • Image()
  • Audio()
  • Video()
  • File()
  • Button()
  • Payload()
  • Question()
  • Child components

Was this helpful?

Edit on Git
Export as PDF
  1. Sending and Receiving Messages

Message Payloads

Standard message components

CSML message components all have a matching message format for client use in regular JSON. They can be extended by adding additional properties to the content wrapper.

Text()

> Text()
{
  "content": {
    "text": "message"
  },
  "content_type": "text"
}

Typing()

> Typing()
{
  "content": {
    "duration": 1000
  },
  "content_type": "typing"
}

Wait()

> Wait()
{
  "content": {
    "duration": 1000
  },
  "content_type": "wait"
}

Url()

> Url()
{
  "content": {
    "url": "https://example.com",
    "title": "title",
    "text": "text"
  },
  "content_type": "url"
}

Image()

> Image()
{
  "content": {
    "url": "https://example.com/image.jpg",
  },
  "content_type": "image"
}

Audio()

> Audio()
{
  "content": {
    "url": "https://example.com/audio.mp3",
  },
  "content_type": "audio"
}

Video()

> Video()
{
  "content": {
    "url": "https://example.com/video.mp4",
  },
  "content_type": "video"
}

File()

> File()
{
  "content": {
    "url": "https://example.com/video.mp4",
  },
  "content_type": "file"
}

Button()

> Button()
{
  "content": {
    "title": "Button title",
    "payload": "Button payload"
  },
  "content_type": "button"
}

Payload()

> Payload()
{
  "content": {
    "payload": "Custom payload"
  },
  "content_type": "payload"
}

Question()

> Question()
{
  "content": {
    "title": "Question",
    "buttons": [Button]
  },
  "content_type": "question"
}

Child components

Component payloads can be included into one another seamlessly. For example:

// CSML
say Question(
    "Where is Brian",
    buttons = [
        Button("In the kitchen"),
        Button("Somewhere else"),
    ]
)

// JSON output
{
    "content": {
    "title": "Where is Brian",
    "buttons": [
      {
        "content_type": "button",
        "content": {
          "title": "In the kitchen",
        }
      },
      {
        "content_type": "button",
        "content": {
          "title": "Somewhere else",
        }
      },
    ],
  },
  "content_type": "question"
}
PreviousSending and Receiving MessagesNextCustom Components

Last updated 4 years ago

Was this helpful?