A probing service is a service which gathers potential answers to a questions and is different from a pipeline service:

  • it’s activated in parallel together with other probing services. A normal pipeline service is called unless the previous one did not resolve the question. When all probing services are launched in parallel they all potentially find clues and meanings but one assumes that they a priori all have equally valid information about the question. Still, if a probing service decides that it does have the correct answer it can opt to be considered and the only answer returned. If multiple probing services claim to have the ultimate answer the first one will be picked out.
  • it’s being called when normal, sequentially called pipeline services all have failed to find an answer.
  • it’s typically async and uses external services (say Google Map API or Yahoo search)

On a code level there is very little difference between a pipeline service and a probing service; a pipeline service receives an envelope and has access to all that is known about the request while a probing service just gets the question. Both interfaces can easily be interchanged and the main difference is the point in time at which (or positioning of) the service is called.

Qwiery Pipeline

A probing service can be added in the code wherever you like but in order to be used by Qwiery it needs to be added to the array of probing service which can find in the config.js file:

pipeline: [
"Workflow",
"Commands",
"SpecialCases",
"Oracle",
"Deductions",
"Probes",
"NoAnswer",
"Historization",
"Reminders"
],
probingServices :[
"GraphDB/GraphDB",
"Wikipedia/Wikipedia",
"Bing/Bing",
"Dummy/Dummy"
]

 

The Dummy services is the one we create below and sits in the Services\Dummy\Dummy.js file. A probing service needs to implement the tryAnswering method and should return something that the client understands. The default Qwiery client understands various blobs of information called pods. A simple answer has DataType SimpleContent and will be rendered as HTML in the client. In fact, you can return markdown and it will be converted to HTML.

So, the most basic probing service we present here is one that will respond to the question hit me and return a basic answer. The processing can be async or synchronous and for the sake of demonstration we’ll use a Promise to show that the answer returned will work with a delay of five seconds.

module.exports = {
tryAnswering: function(question, ctx) {

 return new Promise(function(resolve, reject) {
 setTimeout(function() {
 if(question.toLowerCase() === "hit me") {
  resolve({
   foundPerfectMatch: true,
   found: {
     "Content": "This was processed async in a 'probing' plugin and pretends to be the right answer.",
     "DataType": "SimpleContent"
   }
 });
}
else
{
 resolve(null);
 }
})
}, 
 parseInt(Math.random() * 5000))
 }
};

As mentioned above, a service can declare that it has found the correct answer and this is shown above with the foundPerfectMatch switch. If this is not the case, the answer returned will be added to the array of answers returned by all probing services. The Qwiery client will list and render the various pods appropriately.

Take a look at the included Bing, Alpha and Wikipedia services to see how an external service can easily be plugged into the framework.