How do I send code snippets in MS Teams using Python's SDK framework?

Question:

I can’t seem to find a way to send code snippets using Python’s SDK module. This is what I’m referring to.

I tried using three backsticks ``` and <codeblock> tags, but these are regular code blocks and not snippet codes.

code_snippet = Activity(
    type=ActivityTypes.message,
    text=f'```pythonn{out}n```',
)
await turn_context.send_activity(code_snippet)

Any help would be greatly appreciated!

Asked By: Eduard Grosu

||

Answers:

The TextFormat property of a message can be used to specify the format of the text. The TextFormat property can be set to plain, markdown, or xml. The default value for TextFormat is markdown.

Example:

IMessageActivity message =  Activity.CreateMessageActivity();
message.Text = "Hello!";
message.TextFormat = "plain";
message.Locale = "en-Us";

Ref Doc: https://learn.microsoft.com/en-us/previous-versions/azure/bot-service/dotnet/bot-builder-dotnet-create-messages?view=azure-bot-service-3.0#customizing-a-message

There is no any text format available for code snippets.

If you wish you can suggest this feature here:
Microsoft Teams Community

Answered By: Nivedipa-MSFT