HTTP service nodes can be used to visit a third party HTTP service and extract values from the JSON result returned from the service. In order to use HTTP service node, there are two steps involved: first, registering an HTTP service, which contains the URL, methods, params and values that need to be extracted. Second, reference that service by using HTTP service nodes while test data can be used without visiting the service.
Click setting button in graph editing page:
Click add service in setting page
Add HTTP service content in pop up window
The HTTP service info page contains below info:
{"coord": {"lon": -0.13,"lat": 51.51},"weather": [{"id": 300,"main": "Drizzle","description": "light intensity drizzle","icon": "09d"}],"base": "stations","main": {"temp": 280.32,"pressure": 1012,"humidity": 81,"temp_min": 279.15,"temp_max": 281.15},"visibility": 10000,"wind": {"speed": 4.1,"deg": 80},"clouds": {"all": 90},"dt": 1485789600,"sys": {"type": 1,"id": 5091,"message": 0.0103,"country": "GB","sunrise": 1485762037,"sunset": 1485794875},"id": 2643743,"name": "London","cod": 200}
Return param name | value | note |
---|---|---|
temp | $.main.temp | The temperature of the location |
pressure | $.main.pressure | The pressure of the location |
speed | $.wind.speed | The wind speed of the location |
lat | $.coord.lat | The latitude of the location |
JsonPath is used as the extract semantics and its detail info can be checked below:https://github.com/json-path/JsonPath
The service registered in the first step can be referenced in HTTP service nodes.
1.2.1 Add an HTTP service node
1.2.2 Reference an HTTP service in HTTP service node
When the user inputs “London, UK”, the bot gets London’s temperature.