Class: SignalWire::Skills::Builtin::GoogleMapsSkill
- Inherits:
-
SkillBase
- Object
- SkillBase
- SignalWire::Skills::Builtin::GoogleMapsSkill
show all
- Defined in:
- lib/signalwire/skills/builtin/google_maps.rb
Instance Attribute Summary
Attributes inherited from SkillBase
#agent, #logger, #params, #swaig_fields
Instance Method Summary
collapse
Methods inherited from SkillBase
#cleanup, #get_global_data, #get_param, #initialize, #instance_key, #required_env_vars, #supports_multiple_instances?, #version
Instance Method Details
#description ⇒ Object
15
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 15
def description; 'Validate addresses and compute driving routes using Google Maps'; end
|
#get_hints ⇒ Object
51
52
53
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 51
def get_hints
%w[address location route directions miles distance]
end
|
#get_parameter_schema ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 70
def get_parameter_schema
{
'api_key' => { 'type' => 'string', 'required' => true, 'hidden' => true, 'env_var' => 'GOOGLE_MAPS_API_KEY' },
'lookup_tool_name' => { 'type' => 'string', 'default' => 'lookup_address' },
'route_tool_name' => { 'type' => 'string', 'default' => 'compute_route' }
}
end
|
#get_prompt_sections ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 55
def get_prompt_sections
[
{
'title' => 'Google Maps',
'body' => 'You can validate addresses and compute driving routes.',
'bullets' => [
"Use #{@lookup_tool} to validate and geocode addresses or business names",
"Use #{@route_tool} to get driving distance and time between two points",
"Address lookup supports spoken numbers (e.g. 'seven one four' becomes '714')",
'You can bias address results toward a known location to find the nearest match'
]
}
]
end
|
#name ⇒ Object
14
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 14
def name; 'google_maps'; end
|
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
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 25
def register_tools
[
{
name: @lookup_tool,
description: 'Validate and geocode a street address or business name using Google Maps',
parameters: {
'address' => { 'type' => 'string', 'description' => 'The address or business name to look up' },
'bias_lat' => { 'type' => 'number', 'description' => 'Latitude to bias results toward (optional)' },
'bias_lng' => { 'type' => 'number', 'description' => 'Longitude to bias results toward (optional)' }
},
handler: method(:handle_lookup)
},
{
name: @route_tool,
description: 'Compute a driving route between two points using Google Maps Routes API',
parameters: {
'origin_lat' => { 'type' => 'number', 'description' => 'Origin latitude' },
'origin_lng' => { 'type' => 'number', 'description' => 'Origin longitude' },
'dest_lat' => { 'type' => 'number', 'description' => 'Destination latitude' },
'dest_lng' => { 'type' => 'number', 'description' => 'Destination longitude' }
},
handler: method(:handle_route)
}
]
end
|
#setup ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/signalwire/skills/builtin/google_maps.rb', line 17
def setup
@api_key = get_param('api_key', env_var: 'GOOGLE_MAPS_API_KEY')
@lookup_tool = get_param('lookup_tool_name', default: 'lookup_address')
@route_tool = get_param('route_tool_name', default: 'compute_route')
return false unless @api_key && !@api_key.empty?
true
end
|