Skip to content

Commit

Permalink
Added support for sending Custom Tags and closing conversation sessio…
Browse files Browse the repository at this point in the history
…ns from BotKit
  • Loading branch information
yesuch-kore committed Oct 31, 2020
1 parent a89ea95 commit 48f7b1c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 6 deletions.
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnAgentTransferPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function OnAgentTransferPayload(requestId, botId, componentId, opts) {
this.metaInfo = opts.metaInfo;
this.resetBotUrl = opts.resetBotUrl;
this.baseUrl = opts.baseUrl;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.metaTags = opts.metaTags;
this.messageObject = opts.messageObject;

this.toJSON = function() {
return {
Expand All @@ -44,7 +48,9 @@ function OnAgentTransferPayload(requestId, botId, componentId, opts) {
skipUserMessageUrl : skipUserMessageUrl,
skipBotMessageUrl : skipBotMessageUrl,
getBotVariableUrl:this.getBotVariableUrl,
overrideMessagePayload: this.overrideMessagePayload
overrideMessagePayload: this.overrideMessagePayload,
metaTags: this.metaTags,
messageObject : this.messageObject
};
};

Expand Down
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnAlertPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function OnAlertPayload(requestId, botId, componentId, opts){
this.context = opts.context;
this.message = opts.message;
this.channel = opts.channel;
this.metaTags = opts.metaTags;
this.messageObject = opts.messageObject;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.toJSON = function() {
return {
__payloadClass : 'OnAlertPayload',
Expand All @@ -42,7 +46,9 @@ function OnAlertPayload(requestId, botId, componentId, opts){
message : this.message,
metaInfo : this.metaInfo,
formattedMessage : this.formattedMessage,
overrideMessagePayload : this.overrideMessagePayload
overrideMessagePayload : this.overrideMessagePayload,
metaTags : this.metaTags,
messageObject : this.messageObject
};
};
}
Expand Down
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnEventPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function OnEventPayload(requestId, botId, componentId, opts){
this.message = opts.message;
this.event = opts.event;
this.agent_transfer = opts.agent_transfer|| false;
this.metaTags = opts.metaTags;
this.messageObject = opts.messageObject;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.toJSON = function() {
return {
__payloadClass : 'OnEventPayload',
Expand All @@ -43,7 +47,9 @@ function OnEventPayload(requestId, botId, componentId, opts){
isTemplate : this.isTemplate,
metaInfo : this.metaInfo,
formattedMessage : this.formattedMessage,
overrideMessagePayload : this.overrideMessagePayload
overrideMessagePayload : this.overrideMessagePayload,
metaTags : this.metaTags,
messageObject : this.messageObject
};
};
}
Expand Down
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnHookPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function OnHookPayload(requestId, botId, componentId, opts) {
this.resetBotUrl = opts.resetBotUrl;
this.getBotVariableUrl = opts.getBotVariableUrl;
this.baseUrl = opts.baseUrl;
this.metaTags = opts.metaTags;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.messageObject = opts.messageObject;

this.toJSON = function() {
return {
Expand All @@ -49,7 +53,9 @@ function OnHookPayload(requestId, botId, componentId, opts) {
context : this.context,
channel : this.channel,
message : this.message,
contextId : this.contextId
contextId : this.contextId,
metaTags : this.metaTags,
messageObject : this.messageObject
};
};

Expand Down
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnMessagePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function OnMessagePayload(requestId, botId, componentId, opts){
this.skipUserMessageUrl = skipUserMessageUrl;
var skipBotMessageUrl = opts.skipBotMessageUrl;
this.skipBotMessageUrl = skipBotMessageUrl;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.resetBotUrl = opts.resetBotUrl;
this.baseUrl = opts.baseUrl;
this.metaInfo = opts.metaInfo;
Expand All @@ -22,6 +24,8 @@ function OnMessagePayload(requestId, botId, componentId, opts){
this.message = opts.message;
this.agent_transfer = opts.agent_transfer|| false;
this.ackMessage = true;
this.metaTags = opts.metaTags;
this.messageObject = opts.messageObject;
this.toJSON = function() {
return {
__payloadClass : 'OnMessagePayload',
Expand All @@ -42,7 +46,9 @@ function OnMessagePayload(requestId, botId, componentId, opts){
metaInfo : this.metaInfo,
formattedMessage : this.formattedMessage,
overrideMessagePayload : this.overrideMessagePayload,
ackMessage: this.ackMessage
ackMessage: this.ackMessage,
metaTags: this.metaTags,
messageObject : this.messageObject
};
};
}
Expand Down
8 changes: 7 additions & 1 deletion lib/sdk/ObjectTypes/OnVariableUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function OnVariableUpdate(requestId, botId, componentId, opts){
this.skipBotMessageUrl = skipBotMessageUrl;
this.resetBotUrl = opts.resetBotUrl;
this.ackMessage = true;
this.metaTags = opts.metaTags;
var clearConversationSessionUrl = opts.clearConversationSessionUrl;
this.clearConversationSessionUrl = clearConversationSessionUrl;
this.messageObject = opts.messageObject;
this.toJSON = function() {
return {
__payloadClass : 'OnVariableUpdate',
Expand All @@ -46,7 +50,9 @@ function OnVariableUpdate(requestId, botId, componentId, opts){
language : this.language,
agent_transfer : this.agent_transfer,
baseUrl : this.baseUrl,
ackMessage : this.ackMessage
ackMessage : this.ackMessage,
metaTags : this.metaTags,
messageObject : this.messageObject
};
};
}
Expand Down
10 changes: 10 additions & 0 deletions lib/sdk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var extendRequestId = invokeSendMessage.extendRequestId;
var fetchBotVariable = invokeSendMessage.fetchBotVariable;
var invokeSkipUserMessage = invokeSendMessage.skipUserMessage;
var invokeSkipBotMessage = invokeSendMessage.skipBotMessage;
var clearConversationSession= invokeSendMessage.clearConversationSession;
var customErrors = require("./sdkerrors");
var config = require("../../config");
var _ = require('lodash');
Expand Down Expand Up @@ -237,5 +238,14 @@ module.exports = {
return invokeSkipBotMessage(request)
.nodeify(callback);
},
clearConversationSession : function(request, callback) {
if (!request.clearConversationSessionUrl) {
throw new errors.InvalidArguments('clear conversation session url is missing');
}

return clearConversationSession(request)
.nodeify(callback);
},


};
7 changes: 7 additions & 0 deletions lib/sdk/lib/invokeSendMessageAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ module.exports = {
skipBotMessage: function(requestData, callback) {
var url = requestData.skipBotMessageUrl;

return invokeAPI.post(url, requestData.toJSON())
.then(function() {})
.nodeify(callback);
},
clearConversationSession: function(requestData, callback) {
var url = requestData.clearConversationSessionUrl;

return invokeAPI.post(url, requestData.toJSON())
.then(function() {})
.nodeify(callback);
Expand Down

0 comments on commit 48f7b1c

Please sign in to comment.