This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Weather.acdl
120 lines (105 loc) · 4.37 KB
/
Weather.acdl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0
// Licensed under the Amazon Software License http://aws.amazon.com/asl/
// In Alexa Conversations Description Language (ACDL) files, you organize name declarations into namespaces.
// Each ACDL file corresponds to a module that consists of a single namespace declaration.
namespace examples.weatherbot
//ac-core libraries
import com.amazon.alexa.ask.conversations.*
import com.amazon.ask.types.builtins.AMAZON.*
import com.amazon.alexa.schema.Nothing
import com.amazon.alexa.skill.components.feedback_elicitation.*
import prompts.*
import displays.*
multiModalWelcome = MultiModalResponse {
apl = WelcomeAPL,
apla = AlexaConversationsWelcome
}
multiModalweather = MultiModalResponse {
apl = weather_apl,
apla = weather_apla
}
multiModalCity = MultiModalResponse {
apl = request_city_apl,
apla = request_city_apla
}
multiModalDate= MultiModalResponse {
apl = request_date_apl,
apla = request_date_apla
}
multiModalCityDate= MultiModalResponse {
apl = request_city_date_apl,
apla = request_city_date_apla
}
mySkill = skill(
locales = [Locale.en_US],
dialogs = [Weather],
skillLevelResponses = SkillLevelResponses
{
welcome = multiModalWelcome,
out_of_domain = AlexaConversationsOutOfDomain,
bye = AlexaConversationsBye,
reqmore = AlexaConversationsRequestMore,
provide_help = AlexaConversationsProvideHelp
}
)
// Declare a type for the information you want to extract from the utterances
// In this example, we want to extract the name of a city and date
type CityAndDate {
optional US_CITY cityName
optional DATE date
}
// Declare an event using your annotated utterances.
// In the following example, we declare WeatherEvent as the name for our set of annotated utterances.
// In your dialog sample, you use WeatherEvent to describe the user utterance event.
// Note the interpolated strings.
// The ACDL compiler makes sure that {cityName}, {date} matches one of the properties of the WeatherRequest type
getWeatherEvent = utterances<CityAndDate>(
[
"What's the weather {date} in {cityName}",
"what is the weather {date}",
"How is the weather {date}",
"How is weather in {cityName} {date}",
"how is weather",
"can you please give me weather report for {date}"
]
)
// Declare a type for the information you want to return as reponse
type WeatherResult {
US_CITY cityName
NUMBER highTemp
NUMBER lowTemp
}
// Declare the type for the APLA document's payload
type ResponsePayload {
WeatherResult weatherResult
}
// Declare the signature of an action to represent the skill logic
// Describe the interaction using the business logic that is responsible for retrieving the weather forecast for a city.
action WeatherResult getWeather(US_CITY cityName, DATE date)
// Describe the dialog flow
dialog Nothing Weather {
sample {
// Declare the expectation that the user will ask for the weather
weatherRequest = expect(Invoke, getWeatherEvent)
//Represents the requirement that the referenced action argument must be given a value
ensure(
RequestArguments {arguments = [getWeather.arguments.cityName], response = multiModalCity},
RequestArguments {arguments = [getWeather.arguments.date], response = multiModalDate},
RequestArguments {arguments = [getWeather.arguments.cityName, getWeather.arguments.date], response = multiModalCityDate}
)
// Describe the action that represents the skill's logic to retrieve
// the result following the above event
weatherResult = getWeather(weatherRequest.cityName, weatherRequest.date)
// Reusable dialog call -- collects and saves user feedback
// Describe the action that represents the response to the user.
// The "weather_apla" is the name of the APLA document which is
// declared as a separate JSON-based document outside of ACDL.
// The ACDL compiler creates the name automatically in the "prompts" namespace.
elicitRating(
notifyResponse = multiModalweather,
notifyAction = getWeather,
payload = ResponsePayload {weatherResult = weatherResult}
)
}
}