Deleting messages on iOS

Copper Contributor

Hello,

 

I have an MS Teams chatbot; to operate it, we do not use the relevant language SDK (Python) because our app also operates on other platforms, like Slack. The bot is only for 1-on-1 chats.

 

My problem is when we send a multiple-choice question to a user running the iOS Teams app. The intended behavior, which is what we get in all other cases (desktop app, Android, browser, as well as Slack and other platforms) is that, after the user chooses an answer, the buttons all disappear and leave no trace. This is to keep them focused on the current question and avoid getting useless extra answers.

 

On iOS, the buttons do get deleted, but they leave a trace - a gray box stating that a message was deleted. We would like to get rid of that. How do we achieve this? We currently use Hero cards, but have the capability to use Adaptive cards as well. I 

 

Here's the code that sends the delete request:

 

# teams.py

@shared_task
def delete_inline_keyboards_teams(chat, new_message_id):
    with chat.bot.platform.lock(chat.id, 'delete_inline_keyboards'):
        chat_messages_with_buttons = redis_connection.smembers(f'{chat.id}-keyboards')
        for line in chat_messages_with_buttons:
            with Capture():
                message_id, activity_id = line.decode().split(':')
                if int(message_id) < new_message_id:
                    response = chat.bot.platform.delete_activity(chat.service_url, chat.conversation.id, activity_id)
                    if not response.status_code == status.HTTP_200_OK:
                        raise PlatformException(chat.bot.platform.code, response)
                    redis_connection.srem(f'{chat.id}-keyboards', line)

class Teams(Platform):
    def delete_activity(self, base_uri, conversation_id, activity_id):
        headers = {'content-type': 'application/json; charset=utf-8', 'Authorization': f'Bearer {self.access_token}'}
        url = f'/v3/conversations/{conversation_id}/activities/{activity_id}'
        return requests.delete(f'{base_uri}/{url}', headers=headers)

 

 

1 Reply
@brunoparga - Are you deleting question card itself or only removing the buttons from the card?
Could you please also try it with Adaptive Card.