How to intercept bot messages in SDK4
I have an SDK 4 bot, logging user interactions to Blob storage. I would also like to log bot responses also. In SDK 3 I did this with something like ...
bot.use({
// Code for handling message receives
receive: function (session, event, next) {
var userId = session.address.user.id;
logger.logUserConversation(session.text, userId, session.address.conversation.id, userId);
next();
},
// Code for handling message sends
send: function (event, next) {
var text = event.text;
if(!event.text) {
text = "Attachments sent";
}
logger.logUserConversation(text, 'bot', event.address.conversation.id, event.address.user.id);
next();
}
});
In SDK 4, I am able to configure middleware which intercepts user activity, but I cannot seem to intercept bot activity. I can't seem to find anything in the documentation, but I am new to SDK 4 and might be missing something.
Anybody know how I can intercept both user and bot events, so that I can log?
node.js
add a comment |
I have an SDK 4 bot, logging user interactions to Blob storage. I would also like to log bot responses also. In SDK 3 I did this with something like ...
bot.use({
// Code for handling message receives
receive: function (session, event, next) {
var userId = session.address.user.id;
logger.logUserConversation(session.text, userId, session.address.conversation.id, userId);
next();
},
// Code for handling message sends
send: function (event, next) {
var text = event.text;
if(!event.text) {
text = "Attachments sent";
}
logger.logUserConversation(text, 'bot', event.address.conversation.id, event.address.user.id);
next();
}
});
In SDK 4, I am able to configure middleware which intercepts user activity, but I cannot seem to intercept bot activity. I can't seem to find anything in the documentation, but I am new to SDK 4 and might be missing something.
Anybody know how I can intercept both user and bot events, so that I can log?
node.js
add a comment |
I have an SDK 4 bot, logging user interactions to Blob storage. I would also like to log bot responses also. In SDK 3 I did this with something like ...
bot.use({
// Code for handling message receives
receive: function (session, event, next) {
var userId = session.address.user.id;
logger.logUserConversation(session.text, userId, session.address.conversation.id, userId);
next();
},
// Code for handling message sends
send: function (event, next) {
var text = event.text;
if(!event.text) {
text = "Attachments sent";
}
logger.logUserConversation(text, 'bot', event.address.conversation.id, event.address.user.id);
next();
}
});
In SDK 4, I am able to configure middleware which intercepts user activity, but I cannot seem to intercept bot activity. I can't seem to find anything in the documentation, but I am new to SDK 4 and might be missing something.
Anybody know how I can intercept both user and bot events, so that I can log?
node.js
I have an SDK 4 bot, logging user interactions to Blob storage. I would also like to log bot responses also. In SDK 3 I did this with something like ...
bot.use({
// Code for handling message receives
receive: function (session, event, next) {
var userId = session.address.user.id;
logger.logUserConversation(session.text, userId, session.address.conversation.id, userId);
next();
},
// Code for handling message sends
send: function (event, next) {
var text = event.text;
if(!event.text) {
text = "Attachments sent";
}
logger.logUserConversation(text, 'bot', event.address.conversation.id, event.address.user.id);
next();
}
});
In SDK 4, I am able to configure middleware which intercepts user activity, but I cannot seem to intercept bot activity. I can't seem to find anything in the documentation, but I am new to SDK 4 and might be missing something.
Anybody know how I can intercept both user and bot events, so that I can log?
node.js
node.js
asked Nov 16 '18 at 22:39
dividordividor
556
556
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are already 2 samples in Node.js in the official samples repository:
- 1 called "Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/25.logger
- 1 called "transcript Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/26.transcript-logger
I gave a try to the 1st one and can confirm that it logs both user input and bot replies. It is logging every activity, even ConversationUpdate.
See example of transcript generated below:
Activity Received: { type: 'conversationUpdate',
membersAdded: [ { id: '1', name: 'Bot' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '370f7ea0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.689Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { type: 'conversationUpdate',
membersAdded:
[ { id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6', name: 'User' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.705Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { text:
'I am a bot that demonstrates custom logging. We will have a short conversation where I ask a few questions to collect your name and age, then store those values in UserState for later use. after this you will be able to find a log of the conversation in the folder set by the transcriptsPath environment variable Say anything to continue.',
inputHint: 'acceptingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:08.408Z }
Activity Received: { type: 'message',
text: 'test',
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
textFormat: 'plain',
timestamp: 2018-11-19T16:36:23.421Z,
channelData: { clientActivityId: '1542645367574.7109285295569892.0' },
entities:
[ { type: 'ClientCapabilities',
requiresBotState: true,
supportsTts: true,
supportsListening: true } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:23.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
serviceUrl: 'http://localhost:58083' }
Activity Received: { text: 'What is your name, human?',
inputHint: 'expectingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:23.443Z }
More details about the code that generated that is available on the project, here. If you look at it, the main point is:
if (activity.value === 'endOfInput') {
console.log(this.conversations[id]);
var transcriptfileName = util.format('%s/log_%s.transcript', process.env.transcriptsPath, id);
fs.writeFile(transcriptfileName, JSON.stringify(this.conversations[id], null, 3), function(err) {
if (err) throw err;
});
delete this.conversations[id];
}
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346343%2fhow-to-intercept-bot-messages-in-sdk4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are already 2 samples in Node.js in the official samples repository:
- 1 called "Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/25.logger
- 1 called "transcript Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/26.transcript-logger
I gave a try to the 1st one and can confirm that it logs both user input and bot replies. It is logging every activity, even ConversationUpdate.
See example of transcript generated below:
Activity Received: { type: 'conversationUpdate',
membersAdded: [ { id: '1', name: 'Bot' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '370f7ea0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.689Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { type: 'conversationUpdate',
membersAdded:
[ { id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6', name: 'User' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.705Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { text:
'I am a bot that demonstrates custom logging. We will have a short conversation where I ask a few questions to collect your name and age, then store those values in UserState for later use. after this you will be able to find a log of the conversation in the folder set by the transcriptsPath environment variable Say anything to continue.',
inputHint: 'acceptingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:08.408Z }
Activity Received: { type: 'message',
text: 'test',
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
textFormat: 'plain',
timestamp: 2018-11-19T16:36:23.421Z,
channelData: { clientActivityId: '1542645367574.7109285295569892.0' },
entities:
[ { type: 'ClientCapabilities',
requiresBotState: true,
supportsTts: true,
supportsListening: true } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:23.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
serviceUrl: 'http://localhost:58083' }
Activity Received: { text: 'What is your name, human?',
inputHint: 'expectingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:23.443Z }
More details about the code that generated that is available on the project, here. If you look at it, the main point is:
if (activity.value === 'endOfInput') {
console.log(this.conversations[id]);
var transcriptfileName = util.format('%s/log_%s.transcript', process.env.transcriptsPath, id);
fs.writeFile(transcriptfileName, JSON.stringify(this.conversations[id], null, 3), function(err) {
if (err) throw err;
});
delete this.conversations[id];
}
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
add a comment |
There are already 2 samples in Node.js in the official samples repository:
- 1 called "Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/25.logger
- 1 called "transcript Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/26.transcript-logger
I gave a try to the 1st one and can confirm that it logs both user input and bot replies. It is logging every activity, even ConversationUpdate.
See example of transcript generated below:
Activity Received: { type: 'conversationUpdate',
membersAdded: [ { id: '1', name: 'Bot' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '370f7ea0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.689Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { type: 'conversationUpdate',
membersAdded:
[ { id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6', name: 'User' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.705Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { text:
'I am a bot that demonstrates custom logging. We will have a short conversation where I ask a few questions to collect your name and age, then store those values in UserState for later use. after this you will be able to find a log of the conversation in the folder set by the transcriptsPath environment variable Say anything to continue.',
inputHint: 'acceptingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:08.408Z }
Activity Received: { type: 'message',
text: 'test',
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
textFormat: 'plain',
timestamp: 2018-11-19T16:36:23.421Z,
channelData: { clientActivityId: '1542645367574.7109285295569892.0' },
entities:
[ { type: 'ClientCapabilities',
requiresBotState: true,
supportsTts: true,
supportsListening: true } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:23.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
serviceUrl: 'http://localhost:58083' }
Activity Received: { text: 'What is your name, human?',
inputHint: 'expectingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:23.443Z }
More details about the code that generated that is available on the project, here. If you look at it, the main point is:
if (activity.value === 'endOfInput') {
console.log(this.conversations[id]);
var transcriptfileName = util.format('%s/log_%s.transcript', process.env.transcriptsPath, id);
fs.writeFile(transcriptfileName, JSON.stringify(this.conversations[id], null, 3), function(err) {
if (err) throw err;
});
delete this.conversations[id];
}
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
add a comment |
There are already 2 samples in Node.js in the official samples repository:
- 1 called "Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/25.logger
- 1 called "transcript Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/26.transcript-logger
I gave a try to the 1st one and can confirm that it logs both user input and bot replies. It is logging every activity, even ConversationUpdate.
See example of transcript generated below:
Activity Received: { type: 'conversationUpdate',
membersAdded: [ { id: '1', name: 'Bot' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '370f7ea0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.689Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { type: 'conversationUpdate',
membersAdded:
[ { id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6', name: 'User' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.705Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { text:
'I am a bot that demonstrates custom logging. We will have a short conversation where I ask a few questions to collect your name and age, then store those values in UserState for later use. after this you will be able to find a log of the conversation in the folder set by the transcriptsPath environment variable Say anything to continue.',
inputHint: 'acceptingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:08.408Z }
Activity Received: { type: 'message',
text: 'test',
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
textFormat: 'plain',
timestamp: 2018-11-19T16:36:23.421Z,
channelData: { clientActivityId: '1542645367574.7109285295569892.0' },
entities:
[ { type: 'ClientCapabilities',
requiresBotState: true,
supportsTts: true,
supportsListening: true } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:23.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
serviceUrl: 'http://localhost:58083' }
Activity Received: { text: 'What is your name, human?',
inputHint: 'expectingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:23.443Z }
More details about the code that generated that is available on the project, here. If you look at it, the main point is:
if (activity.value === 'endOfInput') {
console.log(this.conversations[id]);
var transcriptfileName = util.format('%s/log_%s.transcript', process.env.transcriptsPath, id);
fs.writeFile(transcriptfileName, JSON.stringify(this.conversations[id], null, 3), function(err) {
if (err) throw err;
});
delete this.conversations[id];
}
There are already 2 samples in Node.js in the official samples repository:
- 1 called "Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/25.logger
- 1 called "transcript Logger": https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/26.transcript-logger
I gave a try to the 1st one and can confirm that it logs both user input and bot replies. It is logging every activity, even ConversationUpdate.
See example of transcript generated below:
Activity Received: { type: 'conversationUpdate',
membersAdded: [ { id: '1', name: 'Bot' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '370f7ea0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.689Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { type: 'conversationUpdate',
membersAdded:
[ { id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6', name: 'User' } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:07.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
timestamp: 2018-11-19T16:36:07.705Z,
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
serviceUrl: 'http://localhost:58083' }
Activity Received: { text:
'I am a bot that demonstrates custom logging. We will have a short conversation where I ask a few questions to collect your name and age, then store those values in UserState for later use. after this you will be able to find a log of the conversation in the folder set by the transcriptsPath environment variable Say anything to continue.',
inputHint: 'acceptingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '3711c890-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:08.408Z }
Activity Received: { type: 'message',
text: 'test',
from:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
locale: '',
textFormat: 'plain',
timestamp: 2018-11-19T16:36:23.421Z,
channelData: { clientActivityId: '1542645367574.7109285295569892.0' },
entities:
[ { type: 'ClientCapabilities',
requiresBotState: true,
supportsTts: true,
supportsListening: true } ],
channelId: 'emulator',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
id: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
localTimestamp: 2018-11-19T16:36:23.000Z,
recipient: { id: '1', name: 'Bot', role: 'bot' },
serviceUrl: 'http://localhost:58083' }
Activity Received: { text: 'What is your name, human?',
inputHint: 'expectingInput',
channelId: 'emulator',
serviceUrl: 'http://localhost:58083',
conversation: { id: '36e25420-ec19-11e8-8040-2ba105e71021|livechat' },
from: { id: '1', name: 'Bot', role: 'bot' },
recipient:
{ id: 'fd3fd64d-6297-4e36-98c5-ee398857f2b6',
name: 'User',
role: 'user' },
replyToId: '406fdad0-ec19-11e8-9ee4-fb60855d29c5',
type: 'message',
timestamp: 2018-11-19T16:36:23.443Z }
More details about the code that generated that is available on the project, here. If you look at it, the main point is:
if (activity.value === 'endOfInput') {
console.log(this.conversations[id]);
var transcriptfileName = util.format('%s/log_%s.transcript', process.env.transcriptsPath, id);
fs.writeFile(transcriptfileName, JSON.stringify(this.conversations[id], null, 3), function(err) {
if (err) throw err;
});
delete this.conversations[id];
}
answered Nov 19 '18 at 16:38
Nicolas RNicolas R
9,15521743
9,15521743
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
add a comment |
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
Doh! Should have spotted those. Thanks a lot.
– dividor
Nov 21 '18 at 1:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346343%2fhow-to-intercept-bot-messages-in-sdk4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown