Skip to content

Commit

Permalink
Merge branch 'hotfix/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
webus committed Aug 20, 2017
2 parents 7cb442e + 7aa3ae9 commit 72b5023
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botstack",
"version": "0.1.0",
"version": "0.1.2",
"description": "Bot Stack",
"main": "index.js",
"scripts": {
Expand Down
41 changes: 6 additions & 35 deletions src/api-ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ function getApiAiInstance() {
return instance;
}

async function backchatApiAiSync(response) {
async function backchatApiAiSync(response, senderID) {
if (process.env.BACKCHAT_APIAI_SYNC_URL) {
const reqData = {
url: process.env.BACKCHAT_APIAI_SYNC_URL,
resolveWithFullResponse: true,
method: 'POST',
json: response
json: {
sender_id: senderID,
response
}
};
try {
const result = await rp(reqData);
Expand Down Expand Up @@ -96,40 +99,8 @@ function getApiAiResponse({ apiAiRequest, senderID, eventName, message, sessionI

log.debug('API.AI responded', logParams);

backchatApiAiSync(response);
backchatApiAiSync(response, senderID);
resolve(processResponse(response, senderID));

/*
if (lodash.get(response, 'result')) {
log.debug('API.AI result', {
module: 'botstack:api-ai',
senderId: senderID,
result: response.result
});
const responseText = lodash.get(response.result, 'fulfillment.speech');
const responseData = lodash.get(response.result, 'fulfillment.data');
const messages = lodash.get(response.result, 'fulfillment.messages');
const action = lodash.get(response.result, 'action');
if (lodash.get(responseData, 'facebook')) {
// FIXME: implement this type of messages
log.debug('Response as formatted message', {
module: 'botstack:api-ai',
senderId: senderID
});
resolve(null);
} else if (!lodash.isEmpty(messages)) {
const returnData = {
messages,
response
};
resolve(returnData);
}
} else {
resolve(null);
}
*/
});

apiAiRequest.on('error', (error) => {
Expand Down

0 comments on commit 72b5023

Please sign in to comment.