Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article we will talk about the EDDI's http calls httpCalls feature.

The http calls feature httpCalls feature allows a chatbot to consume 3rd party APIs or even your own api APIs  and use the JSON response in another http call or in EDDIanother 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!

...

Code Block
languagejs
themeEclipse
linenumberstrue
{
  "targetServer": "string",
  "httpCalls": [
    {
      "name": "string",
      "saveResponse": true,
      "responseObjectName": "string",
      "actions": [
        "string"
      ],
      "request": {
        "path": "string",
        "headers": {},
        "queryParams": {},
        "method": "string",
        "contentType": "string",
        "body": "string"
      },
      "postResponse": {
        "qrBuildInstruction": {
     }    ]
}

Description  :

...

 "pathToTargetArray": "String",
          "iterationObjectName": "String",
          "quickReplyValue": "String",
          "quickReplyExpressions": "String"
        }
      }
    }
  ]
}

Description  :

an http call 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.

You can ${memory.current.httpCalls.<responseObjectName>} to access your JSON object, so you can use it in output templating or in another http call, for example an http call will get the oAuth token and another http call will use in the http headers to authenticate to an api.


headers: key,value) for each http call header
targetServer(Stringroot/context path of the http call (e.g http://example.com/api)
httpCall.saveResponse(Boolean) whether to save the json response into ${memory.current.httpCalls}
httpCall.responseObjectName(Stringname of the json object so it can be accessed from other http calls or outputsets.
httpCall.actions(String) name of the output/behavior set mapped to this http call.
httpCall.request.path(String) path of the http call  (e.g /books)
httpCall.request.headers(String: key,valuefor each http call header
httpCall.request.queryParams(String: key,value) for each http call query parameter
httpCall.request.method(StringHttp method of the http call (e.g GET,POST,etc...)
httpCall.request.contentType(String) value of the contentType header of the http call
httpCall.request.body(String) an escaped JSON object that goes in the http request body if needed.
httpCall.requestpostResponse.qrBuildInstruction.queryParamspathToTargetArray(String: key,value) for each http call query parameter) path to the array in your JSON response data
httpCall.requestpostResponse.qrBuildInstruction.methoditerationObjectName(String) Http method of the http calla variable name that will point to the TargetArray.
httpCall.requestpostResponse.qrBuildInstruction.contentTypequickReplyValue(String) value of the contentType header of the http callhttpCall.request.body(String) in escaped json value of the request body if applicablethymeleaf expression to use as a quick reply value.
httpCall.postResponse.qrBuildInstruction.quickReplyExpressions(String) expression to retreive a property from iterationObjectName.

The API endpoints :

HTTP MethodAPI EndpointRequest BodyResponse
DELETE /httpcallsstore/httpcalls/{id}N/AN/A
GET /httpcallsstore/httpcalls/{id}N/Ahttp-call-model
PUT /httpcallsstore/httpcalls/{id}http-call-modelN/A
GET /httpcallsstore/httpcalls/descriptorsN/Alist of references to http-call-model
POST /httpcallsstore/httpcallshttp-call-modelN/A
GET /httpcallsstore/httpcalls/{id}/currentversionN/Ahttp-call-model
POST /httpcallsstore/httpcalls/{id}/currentversionhttp-call-modelN/A

...

Step by step example :

We will do a step by step example from scratch (chatbot creation to a simple conversation that uses http call)

...