1.0.2 • Published 8 years ago

flocktoapiai v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

##Flock.to - Api.ai Integeration

This module is an SDK for making applications in flock using APi.ai.


####Module and Calls

flocktoapiai module is called using flockAccessToken, apiaiAccessToken, optionsFlock, optionsApiai

optionsFlock and optionsApiai are JSON objects. Required fields in optionsFlock are "botID", "port" and "endPoint" optionsApiai is optional and depends upon one's interaction with Apiai.


####Sample Code -

var flocktoapiai = require("flocktoapiai");
var flockAccessToken = "< your flockAccessToken >" ;
var apiaiAccessToken = " < your apiaiAccessToken > ";
var app = flocktoapiai(flockAccessToken,apiaiAccessToken,{"botID":"< Your BotID >","port": port::Integer,"endPoint":"<endPoin>"});
app.on('data',function(ob){
	if(ob.apiaiResponse.result.metadata.intentName=='Intent which you are handling'){

		-- Your code here--

		-- ob is object where ob.apiaiResponse is response of api.ai and 
							---ob.sessionId is the sessionId of current user.
	}
});

####Sample code for sending a message var nMsg = new app.newMessage(); nMsg.setTo(ob.sessionId); nMsg.setText(ob.text);

/* Example of Image Sending*/

nMsg.sendImg("your image url");
nMsg.setHeigthtandWidth(1000,1000);
app.send(nMsg);

####Example

You can check github repo (https://github.com/talk-to/NLPBots or example section in module) for an example for sample weather application. An example of sending image is also illustrated in weatherbot.