Forum Discussion
Error when trying to update adaptive card
Please have another look at the Azure Bot configuration for the correct Bot ID from there is mentioned in your code configuration.
Also, as you have channelized the bot to MS Teams, have a look if there are any errors reported.
Please find logs below
[Message does not exist in the thread.
Error: Message does not exist in the thread.
at new RestError (node_modules/@azure/ms-rest-js/dist/msRest.node.js:1403:28)
at /node_modules/@azure/ms-rest-js/dist/msRest.node.js:2528:37
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async fnc.]
- Nivedipa-MSFTSep 06, 2022
Microsoft
To update the existing card on button selection, you can use
ReplyToIdof incoming activity.To update existing card on a button selection, pass a new
Activityobject with updated card andReplyToIdas activity ID to theUpdateActivityAsyncmethod of theTurnContextclass. See TurnContextClass.var activity = MessageFactory.Attachment(card.ToAttachment()); activity.Id = turnContext.Activity.ReplyToId; await turnContext.UpdateActivityAsync(activity, cancellationToken);Ref Doc: Update and delete messages sent from your bot - Teams | Microsoft Docs
- AyeshaKulsumSJSep 12, 2022Brass Contributor
Is there a way to batch send/update the messages and how to reply to the message and update this message also later?
It will be helpful if you can send the documents required.
- Nivedipa-MSFTSep 13, 2022
Microsoft
AyeshaKulsumSJ - We are checking this internally. We will update you soon.
- AyeshaKulsumSJSep 08, 2022Brass Contributor
Nivedipa-MSFT What if I want to update the adaptive card at some scheduled time? If I store ReplyToId or message id. How I can update a card or message in a particular channel at some point in time?
What are the details I should store and How I can update the card later? And Is there a way to batch update the messages and how to reply to the message and update this message also later?
It will be helpful if you can send the documents required.
- AyeshaKulsumSJSep 09, 2022Brass Contributorconst {BotFrameworkAdapter, TurnContext, TeamsInfo, CardFactory, MessageFactory} = require('botbuilder');const properties = {'membersAdded': [{ 'id': '28:17a' }], 'type': 'conversationUpdate', 'timestamp': '2022-08-11T10:54:30.482Z', 'id': 'f:ce9c82ab7a6feabc', 'channelId': 'msteams', 'serviceUrl': 'https://smba.trafficmanager.net/in/', 'from': { 'id': '29:1YqsjLwgg-0A_V8tL5P3hIw', 'aadObjectId': 'a0858f3e-d57759' }, 'conversation': {'isGroup': true, 'conversationType': 'channel', 'tenantId': '3272b84e1', 'id': '19:PZppMpIo1@thread.tacv2'}, 'recipient': { 'id': '28:17720bfc7ba', 'name': 'bot 1' }, 'channelData': {'team': { 'aadGroupId': '9ffd4120579', 'name': 'Ayesha Testing', 'id': '19:PZp9pIo1@thread.tacv2' }, 'eventType': 'teamMemberAdded', 'tenant': { 'id': '3284e1' }, 'settings': { 'selectedChannel': { 'id': '19:PZ1@thread.tacv2' } }}};const BotConnector = require('botframework-connector');const adapter = new BotFrameworkAdapter({appId: '',appPassword: ''});BotConnector.MicrosoftAppCredentials.trustServiceUrl(properties.serviceUrl);const context = new TurnContext(adapter, properties);var message1 = await context.sendActivity('Hi');console.log(message1);var reference = TurnContext.getReplyConversationReference(context.activity, message1);console.log(reference);I am sending message as above and storing details required. Then later at some scheduled timed I have to update message to some other message as below. But it is not working as expected.const newActivity = MessageFactory.attachment({'type': 'AdaptiveCard','$schema': 'http://adaptivecards.io/schemas/adaptive-card.json','version': '1.5','body': [{'type': 'TextBlock','text': 'Nobody has replied to this poll yet','wrap': true}]});BotConnector.MicrosoftAppCredentials.trustServiceUrl(properties.serviceUrl);const newcontext = new TurnContext(adapter, properties);newActivity.id = reference.activityId;console.log(newcontext);newcontext.updateActivity(newActivity);Logs -(node:19905) UnhandledPromiseRejectionWarning: Error: ContentType of an attachment is not set
at new RestError (/Users/ayeshakulsumsj/Documents/project/app/app-v1/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1403:28)
at /Users/ayeshakulsumsj/Documents/project/app/app-v1/node_modules/@azure/ms-rest-js/dist/msRest.node.js:2528:37
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19905) UnhandledPromiseRejectionWarning: