httpCalls
feature (calling other JSON
APIs).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!httpCall
model and go through an example step by step, you can also download the example in Postman collection format and run the steps.httpCall
is mainly composed from the targetServer
array
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
.${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 oAuth
token
and another httpCall
will use in the http
headers
to authenticate to an API.String
) root/context
path of the httpCall
(e.g http://example.com/api)
Boolean
) whether to save the JSON
response into ${memory.current.httpCalls}
Boolean
) whether to execute the request without waiting for a response to be returned, (useful for POST
)String
) name of the JSON
object so it can be accessed from other httpCalls
or outputsets
.String
) name of the output
/behavior
set mapped to this http call.String
) JSON
path to the target array to be used as body of requests e.g: "memory.current.output
"String
) name of the variable to be used for each element of array found in pathToTargetArray
String
) path in the targetServer
of the httpCall
(e.g /books
)Array
:<key, value> ) for each httpCall HTTP header
Array
: <key, value>) for each httpCall
query parameterString
) HTTP
Method of the httpCall
(e.g GET
,POST
,etc...)String
) value of the contentType HTTP header
of the httpCall
String
) an escaped JSON
object that goes in the HTTP Request
body if needed.String
) path to the array in your JSON
response data.String
) a variable name that will point to the TargetArray.
String
) thymeleaf expression
to use as a quickReply
value.String
) expression
to retrieve a property from iterationObjectName
.String
) name of property to be used in templatingString
) a static value can be set here if fromObjectPath
is not defined./httpcallsstore/httpcalls
/httpcallsstore/httpcalls/descriptors
/httpcallsstore/httpcalls/{id}
/httpcallsstore/httpcalls/{id}
/httpcallsstore/httpcalls/{id}
/httpcallsstore/httpcalls/{id}/currentversion
/httpcallsstore/httpcalls/{id}/currentversion
httpCall
)POST
http://localhost:7070/regulardictionarystore/regulardictionaries
no content
201
POST
http://localhost:7070/behaviorstore/behaviorsets
no content
201
[[${memory.current.input}]]
POST
http://localhost:7070/httpcallsstore/httpcalls
no content
201
Note When you set"saveResponse" : true
inhttpCall
then you can use[[${memory.current.httpCalls.<responseObjectName>}]]
to access the response data and usethymeleaf
(th:each
) to iterate overJSON
arrays
if you have them in yourJSON
response.
POST
http://localhost:7070/outputstore/outputsets
no content
201
Important Package note
ai.labs.httpcalls
&ai.labs.output
must come afterai.labs.behavior
in order of the package definitionai.labs.templating
has to be afterai.labs.output
POST
http://localhost:7070/packagestore/packages
no content
201
POST
http://localhost:7070/botstore/bots
no content
201
POST
http://localhost:7070/administration/restricted/deploy/**<bot_id>**?version=1&autoDeploy=true
no content
202
POST
http://localhost:7070/bots/**<env>**/**<bot_id>**
no content
201
POST
http://localhost:7070/bots/<env>/<bot_id>/<conversation_id>?returnDetailed=false&returnCurrentStepOnly=true
200
POST
http://localhost:7070/bots/<env>/<bot_id>/<conversation_id>?returnDetailed=false&returnCurrentStepOnly=true
200