I was doing a proof of concept trying to integrate BotFramework with Amazon lex and finally integrate the bot to Microsoft teams channel. The AWS-SDK is used to call the Amazon Lex bot.
async callLex(context) {
let msg
var lexruntime = new AWS.LexRuntime();
const params = {
botAlias: 'tutorialbot',
botName: 'TutorialBot',
inputText: context.activity.text.trim(), /* required */
userId: context.activity.from.id,
//inputStream: context.activity.text.trim()
}
await lexruntime.postText(params, function(err,data) {
console.log("Inside the postText Method")
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data)
msg = data.message
console.log("This is the message from Amazon Lex" + msg)
context.sendActivity(MessageFactory.text(msg));
//turnContext.sendActivity(msg);
}
console.log("Completed the postText Method")
})
return msg;
}
The response from Lex is received and When i try to return the same response back context.sendActivity(MessageFactory.text(msg)) in the callback function to BotFramework throws an error
Blockquote TypeError: Cannot perform 'get' on a proxy that has been revoked at Response. (E:\playground\BotBuilder-Samples\samples\javascript_nodejs\02.echo-bot\lexbot.js:93:25) at Request. (E:\playground\BotBuilder-Samples\samples\javascript_nodejs\02.echo-bot\node_modules\aws-sdk\lib\request.js:369:18) at Request.callListeners (E:\playground\BotBuilder-Samples\samples\javascript_nodejs\02.echo-bot\node_modules\aws-sdk\lib\sequential_executor.js:106:20) at Request.emit (E:\playground\BotBuilder-Samples\samples\javascript_nodejs\02.echo-bot\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
It seems once the message is sent to Lex, the proxy that the bot uses is no longer available. Can you give some pointers on how to fix this.
This is the calling code invoking the async function callLex
class TeamsConversationBot extends TeamsActivityHandler {
constructor() {
super();
this.onMessage(async (context, next) => {
TurnContext.removeRecipientMention(context.activity);
var replyText = `Echo: ${ context.activity.text }`;
await this.callLex(context)
console.log("After calling the callLex Method")
await next();
});
this.onMembersAddedActivity(async (context, next) => {
context.activity.membersAdded.forEach(async (teamMember) => {
if (teamMember.id !== context.activity.recipient.id) {
await context.sendActivity(`Hi, I'm a TutorialBot. Welcome to the team ${ teamMember.givenName } ${ teamMember.surname }`);
}
});
await next();
});
}