Search code examples
node.jsbotframeworkmicrosoft-teams

Microsoft teams delete an adaptive card using activity id


I am using nodejs and able to show an adaptive card with action as below

{
                "type": "Action.Submit",
                "title": "Hide details",
                "data": { "action" : "hideDetails", "activity_id": context.activity.id}
            }

....
await context.sendActivity(myCard);

so basically on the button, i am passing the activity id of the current context.

now on the hideDetails the code looks like below

 async hideDetails(context:any, activityId:any){
        await context.deleteActivity(activityId)
}

However, I am getting below error

Invalid activity ID f:ef8e3a07-59fe-2eb9-a717-e89c0ca664ba
    at new RestError (/workspace/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1397:28)

what's wrong here?


Solution

  • Copying the answer from comments for better visibility.

    ReplyToId of the Activity Property can be used to Update or delete the message posted to the bot and this is illustrated in Teams Conversation Bot code sample.