0
votes

I have a working C# bot for Teams client, but I need to have the same in node.js. I have a problem when I need to update a message I sent, without the Context.

In my C# code, I send a message and save the activity id and the conversation Id where it is sent. To update this activity (when required), I create a new activity and use this saved id:

var activityIdSaved = "xxx";
var conversationId_saved = "yyyyy";

var activity = Bot.Schema.Activity.CreateMessageActivity();
activity.Id = activityIdSaved; // set Id (saved activity Id)
activity.Text = "This is updated text";

await connectorClient.Conversations.UpdateActivityAsync(conversationId_saved, activityIdSaved, (Bot.Schema.Activity)activity);

This works properly in C#, but I can not find which method to use in node.js for the same purpose...

Thanks,

Diego

2

2 Answers

1
votes

It's pretty much the same thing except that ConnectorClient needs a baseUri. Something like this:

const connectorClient = new ConnectorClient(new MicrosoftAppCredentials('<yourAppId>', '<yourAppPassword>'), { baseUri: teamsServiceUrl });

const activity = MessageFactory.text("This is updated text");
activity.id = activityIdSaved;

await connectorClient.conversations.updateActivity(conversationId_saved, activityIdSaved, activity as Activity);

teamsServiceUrl varies by where the user communicates from. For me, it's https://smba.trafficmanager.net/amer/, but you'll likely need to grab it dynamically from activity.serviceUrl.

I'm not sure why you need to manually set activity.id and also pass it into updateActivity, but I couldn't get it to work, otherwise.

1
votes

@Deigo Since you have already implemented this in C#, here is a sample to update message in NodeJS. Please try out the sample and let us know if you face any issues.