I am using microsoft bot framework and trying to integrate it with external HTTP calls.
However when i invoke the BotWorker.say in the handler BotKitConversation's ask i start getting
(node:5711) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot perform 'get' on a proxy that has been revoked
Below is my code
In my handler function's callback i get some values returned from external function. Then i try to perform bot.say on the response returned and i recieve the above mentioned error.
myDialog.ask('What would like to hear?', [
{
pattern: '.*',
handler: async (response, convo, bot) => {
await YoutubeHelper.getChannel(response, convo,async function(channels){
console.log("value returned " + channels.length);
try {
await bot.say('Printing values'); //error comes here
if (channels.length == 0) {
await bot.say('No items found.');
} else {
await bot.say('This items\'s ID is %s. Its title is \'%s\', and ' ,
channels[0].id,
channels[0].snippet.title
);
}
}catch (err) {
console.log('error occurred' , err);
}
});
}
}
], {key: 'name'});
}
where myDialog is an object of BotkitConversation.
Below is the code for my external utility class
/**
* Lists the names and IDs of up to 10 files.
*
*
*/
var {google} = require('googleapis');
var {myDialog} = require("./bot")
const getChannel = function getChannel(searchTerm, convo,callback) {
var service = google.youtube({
version : 'v3',
auth : '<client id>'});
service.search.list({
part: 'id,snippet',
q: searchTerm
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
var channels = response.data.items;
if (channels.length == 0) {
console.log('No items found.');
} else {
console.log('This items\'s ID is %s. Its title is \'%s\', and ' ,
channels[0].id,
channels[0].snippet.title
);
}
console.log(channels.length);
callback(channels);
});
//
}
module.exports ={
getChannel
}
I found this document regarding the error . I am coding according to the guidelines mentioned.
Best Regards,
Saurav