Forum Discussion
AyeshaKulsumSJ
Sep 04, 2022Brass Contributor
Error when trying to update adaptive card
I am trying to update the adaptive card in a channel with the click of a button in the Personal bot. But I get the following error. Error: Message does not exist in the thread. const newActivity =...
AyeshaKulsumSJ
Sep 09, 2022Brass Contributor
const {
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:
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:
AyeshaKulsumSJ
Sep 11, 2022Brass Contributor
AyeshaKulsumSJ Issue is fixed