Getting to know ACDL

ACDL is a language created specifically to make easy work of defining conversation models for Alexa skills. If you’re familiar with languages like Java and C#, ACDL will be syntactically familiar, but is more declarative in nature than those other languages.

Because ACDL is a rich and expressive language for defining conversation models, there’s no space to go over it in detail in this chapter. Instead, we’ll cover a few ACDL basics and then focus on the aspects of ACDL necessary to define a conversation model suitable for scheduling trips to planetary destinations. For a thorough understanding of ACDL, check out the ACDL Reference.[43]

ACDL source files are created in a skill project’s skill-package/conversations directory and have a .acdl file extension. You can use as few or as many ACDL source files as you’d like to define a conversation model, but it’s typically best for the sake of organization to split the model across multiple ACDL files.

ACDL files are declared as being in a namespace using the namespace keyword at the beginning of the file. For example:

 namespace com.starport75

This is quite similar to the namespace keyword in C# or the package keyword in Java, allowing related resources to be conceptually collected in a given namespace. Resources from different namespaces can be imported into an ACDL file using the import keyword. For example, the following two lines import several components commonly used from the com.amazon.alexa.ask.conversations namespace, as well as the Nothing type from the com.amazon.alexa.schema namespace:

 import com.amazon.alexa.ask.conversations.*
 import com.amazon.alexa.schema.Nothing

One thing you might have already noticed about ACDL that is different from Java or C# is that the lines do not end with a semi-colon. In fact, semi-colons aren’t necessary (or even allowed) in ACDL to designate the end of a line.

The remainder of an ACDL file, following the namespace and import lines, is where you’ll define one or more conversational components such as events, actions, custom types, and dialogs.

Now that we have established a few ACDL basics, let’s put it to work defining the conversation model for the Star Port 75 Travel skill.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset