In this article we will talk about EDDI's httpCallsfeature (calling other JSON APIs).
The httpCalls feature allows a Chatbot to consume 3rd party APIs and use the JSON response in another httpCall (for authentication or requesting a token for instance) or directly print the results in Chatbot's Output, this means, for example, you can call a weather API and use the JSON response in your Chatbot's output if the user asks about today's weather or the week's forecast!
We will emphasize the httpCall model and go through an example step by step, you can also download the example in Postman collection format and run the steps.
An httpCall is mainly composed from the targetServerarray of httpCalls, the latter will have request where you put all details about your actual http request (method,path,headers, etc..) and postResponse where you can define what happens after the httpCall has been executed and a response has been received; such as quick replies by using qrBuildInstruction.
You can use ${memory.current.httpCalls.<responseObjectName>} to access your JSON object, so you can use it in output templating or in another httpCall, for example an httpCall will get the oAuthtoken and another httpCall will use in the httpheaders to authenticate to an API.
Description of the model
Element
Description
targetServerUrl
(String) root/context path of the httpCall (e.g http://example.com/api)
httpCall.saveResponse
(Boolean) whether to save the JSON response into ${memory.current.httpCalls}
httpCall.fireAndForget
(Boolean) whether to execute the request without waiting for a response to be returned, (useful for POST)
httpCall.responseObjectName
(String) name of the JSON object so it can be accessed from other httpCalls or outputsets.
httpCall.actions
(String) name of the output/behavior set mapped to this http call.
Note When you set "saveResponse" : true in httpCall then you can use [[${memory.current.httpCalls.<responseObjectName>}]] to access the response data and use thymeleaf( th:each ) to iterate over JSONarrays if you have them in your JSON response.