fossasia / susi_server

SUSI.AI server backend - the Artificial Intelligence server for personal assistants https://susi.ai
GNU Lesser General Public License v2.1
2.51k stars 1.08k forks source link

Very simple JSON responses cannot be used in skills #1394

Closed marcnause closed 5 years ago

marcnause commented 5 years ago

Many services don't respond with arrays of elements (like a list of search results), they just return simple key/value pairs instead.

Example: https://api.hostip.info/get_json.php?ip=80.122.124.100 returns the following result:

{ "country_name": "AUSTRIA", "country_code": "AT", "city": "Vienna", "ip": "80.122.124.100" }

When the user creates a skill with a service like that, it is not possible to access the data yet. because the path of the skill cannot be set to reference the whole response.

It should be possible to define a path which references the whole result instead of an element in the result.

Orbiter commented 5 years ago

fixed with https://github.com/fossasia/susi_server/commit/f5f08bac7b4d81f429a334b4cf1e1a6f6cbbb2ef

The skill for this would look like

origin of *
!console:$!$
{
  "url":"https://api.hostip.info/get_json.php?ip=$1$",
  "path":"$.city"
}
eol