Conversation Transcript with Bot Framework
// Read more on http://www.pveller.com/smarter-conversations-part-4-transcript/ | |
const transcript = function (session, direction, message, next) { | |
session.privateConversationData.transcript = session.privateConversationData.transcript || []; | |
session.privateConversationData.transcript.push({ | |
direction, | |
message, | |
timestamp: new Date().toUTCString() | |
}); | |
if (next) { | |
session.options.onSave(next); | |
} | |
}; | |
bot.on('routing', function (session) { | |
transcript(session, 'incoming', session.message.text); | |
}); | |
const journal = (direction) => (message, next) => { | |
if (message.type === 'message') { | |
bot.loadSession(message.address, (error, session) => { | |
transcript(session, direction, message.text, next); | |
}); | |
} else { | |
next(); | |
} | |
}; | |
bot.use({ | |
send: journal('outgoing') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment