Target¶
Definition¶
<target>
<http endpoint="http://http-service/function_name"/>
</target>
<target>
<frontend/>
</target>
<target>
<device_module device="NameDevice"/>
</target>
Specifies the target service.
¶
Attribute | Type | Description |
---|---|---|
endpoint | string | Required. The url of the http_service endpoint followed by the name of the function it should run in that endpoint, e.g. 'http://climate-http-service/set_temperature'. |
¶
Attribute | Type | Description |
---|---|---|
device | string | Required. The name of the device module to run. |
Children¶
Behaviour¶
The <target> element in the service interface specifies the target service that will handle its parent <action>, <query>, <validator> or <entity_recognizer>.
¶
Points the parent element to a function of an http_service served on a Flask instance. The DDD sends a request to the http_service, performs the function in it and returns a response.
¶
Points the parent <action> to an integrated frontend service such as Twilio or Alexa. This allows for performing actions like forwarding a call using a frontend service.
¶
Points the parent element to a device module. This will run a class inside the device module which must have the same name as the parent <action>, <query>, etc.
Examples¶
Set the temperature to a specific value using an http_service¶
<action name="SetTemperature">
<parameters>
<parameter predicate="degrees" format="value"/>
</parameters>
<failure_reasons>
<failure_reason name="temperature_too_high"/>
</failure_reasons>
<target>
<http endpoint="http://climate-http-service/set_temperature"/>
</target>
</action>
Forward a Call action to a frontend service¶
<action name="Call">
<parameters>
<parameter predicate="phone_number" format="grammar_entry"/>
</parameters>
<failure_reasons/>
<target>
<frontend/>
</target>
</action>
Query a device module about the current temperature in a location¶
<query name="current_temperature">
<parameters>
<parameter predicate="location" format="grammar_entry"/>
</parameters>
<target>
<device_module device="ClimateDevice"/>
</target>
</query>
Last update: September 25, 2020