Hi,
I am not sure if it this is a correct place for my doubt, but i am a bit desperated
I have a working nodejs bot for Teams client, but I hope my problem is just a ‘javascfipt’ problem
I created my bot with Yeoman:
Now I had a running example which can respond to an incoming message.
My problem is when I want to send a proactive message, I get this error:
“TypeError: source.on is not a function”
My complete code:
I have an index.js file, created automatically, and not modified
And my bot file (bot.js), created automatically, modified to add proactive messages
bot.js code:
“`
const { ConnectorClient, MicrosoftAppCredentials, BotConnector } = require(‘botframework-connector’);
const { ActivityHandler } = require(‘botbuilder’);
class MyBot extends ActivityHandler {
constructor() {
super();
// See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types.
this.onMessage(async (context, next) => {
//await context.sendActivity(`You said ‘${context.activity.text}’`); // It works
var activity = context.activity;
await MicrosoftAppCredentials.trustServiceUrl(activity.serviceUrl);
var connectorClient = new ConnectorClient(credentials, { baseUri: activity.serviceUrl });
const parameters = {
members: [{ id: activity.from.id }],
isGroup: false,
channelData:
{
tenant: {
id: activity.conversation.tenantId
}
}
};
var conversationResource = await connectorClient.conversations.createConversation(parameters);
});
}
module.exports.MyBot = MyBot;
In ‘createConversation’ is where I get the error:
[onTurnError]: TypeError: source.on is not a function
I have a stack trace of the error, and it seems to be related to ‘delayed stream’ node module. I add as a response since it is too long for a comment:
(node:28248) UnhandledPromiseRejectionWarning: TypeError: source.on is not a function
at Function.DelayedStream.create ([Bot Project Path]node_modulesdelayed-streamlibdelayed_stream.js:33:10)
at FormData.CombinedStream.append ([Bot Project Path]node_modulescombined-streamlibcombined_stream.js:45:37)
at FormData.append ([Bot Project Path]node_modulesform-datalibform_data.js:74:3)
at MicrosoftAppCredentials.refreshToken ([Bot Project Path]node_modulesbotframework-connectorlibauthmicrosoftAppCredentials.js:127:20)
at MicrosoftAppCredentials.getToken ([Bot Project Path]node_modulesbotframework-connectorlibauthmicrosoftAppCredentials.js:91:32)
at MicrosoftAppCredentials.signRequest ([Bot Project Path]node_modulesbotframework-connectorlibauthmicrosoftAppCredentials.js:71:38)
at SigningPolicy.signRequest ([Bot Project Path][email protected]:2980:44)
at SigningPolicy.sendRequest ([Bot Project Path][email protected]:2984:21)
at ConnectorClient.ServiceClient.sendRequest ([Bot Project Path][email protected]:3230:29)
at ConnectorClient.ServiceClient.sendOperationRequest ([Bot Project Path][email protected]:3352:27)
This code will be in a method, to call it when required, I put it in ‘onMessage’ just to simplify
I’m afraid I am missing something or doing sth wrong…
Any help will be great,
Diego