-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for HTML messages using teams chat message send
#6483
Comments
Thank you for logging this issue @apc005. |
"text" and "html" are the standard values defined by Microsoft - see https://learn.microsoft.com/fr-fr/graph/api/resources/itembody?view=graph-rest-beta It seems "text" is the default value as this is how M$ graph handles the messages without contentType defined. |
@apc005 are you sure you are using cli-microsoft365/src/m365/teams/commands/message/message-send.ts Lines 74 to 79 in 282b66f
|
My bad I'm using m365 teams chat message send m365 teams chat message send --chatId "$CHAT_ID" -m "Text <b>Bold</b>" --debug Executing command teams chat message send with options {"options":{"chatId":"19:[email protected]","message":"Text <b>Bold</b>","debug":true,"output":"json"}} Executing command as 'xxxx', appId: xxx, tenantId: xxxx Existing access token xxxx still valid. Returning... Request: { "url": "https://graph.microsoft.com/v1.0/chats/19:[email protected]/messages", "method": "post", "headers": { "Accept": "application/json;odata.metadata=none", "Content-Type": "application/json;odata=nometadata", "user-agent": "NONISV|SharePointPnP|CLIMicrosoft365/10.0.0", "accept-encoding": "gzip, deflate", "X-ClientService-ClientTag": "M365CLI:10.0.0", "authorization": "Bearer xxx" }, "responseType": "json", "decompress": true, "data": { "body": { "content": "Text <b>Bold</b>" } } } Response: { "url": "https://graph.microsoft.com/v1.0/chats/19:[email protected]/messages", "status": 201, "statusText": "Created", "headers": { "transfer-encoding": "chunked", "content-type": "application/json;odata.metadata=none;odata.streaming=true;IEEE754Compatible=false;charset=utf-8", "location": "https://teamsgraph.teams.microsoft.com/v1.0/chats('19:[email protected]')/messages('xxxxx')", "vary": "Accept-Encoding", "strict-transport-security": "max-age=31536000", "request-id": "xxxx", "client-request-id": "xxxx", "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"008\",\"RoleInstance\":\"xxxx\"}}", "odata-version": "4.0", "date": "Sat, 09 Nov 2024 21:21:21 GMT", "connection": "close" }, "data": { "id": "xxxx", "replyToId": null, "etag": "1731187281616", "messageType": "message", "createdDateTime": "2024-11-09T21:21:21.616Z", "lastModifiedDateTime": "2024-11-09T21:21:21.616Z", "lastEditedDateTime": null, "deletedDateTime": null, "subject": null, "summary": null, "chatId": "19:[email protected]", "importance": "normal", "locale": "en-us", "webUrl": null, "channelIdentity": null, "policyViolation": null, "eventDetail": null, "from": { "application": null, "device": null, "user": { "id": "xxxx", "displayName": "xxxx", "userIdentityType": "aadUser", "tenantId": "xxxx" } }, "body": { "contentType": "text", "content": "Text <b>Bold</b>" }, "attachments": [], "mentions": [], "reactions": [] } } DONE Timings: api: 1645.839713ms core: 22.843199ms command: 1670.452409ms options: 0.296354ms total: 1697.740365ms validation: 1.658365ms |
You are using |
Yes, my bad. But chat messages do support html too… |
Yes, that's true, but that means it's an enhancement instead of a bug. We can add HTML support for sure. |
teams chat message send
You’re absolutly right. Sorry for the mistake |
No problem at all 😊 |
Enhancement:
Let's add a
--contentType [contentType]
option that acceptstext
andhtml
as values, but defaults totext
.Original issue
Priority
(Medium) I'm annoyed but I'll live
Description
Hi
When using second example on https://pnp.github.io/cli-microsoft365/cmd/teams/message/message-send I don't get a bold message but a text message with html tags:
Running the command with the debug option shows that the contentType is not set in the query:
The response shows it's handled as text:
It would be great to have an option to force the contentType value to "text" or "html"
Thanks
Steps to reproduce
m365 teams message send --teamId XXXXX --channelId YYYY --message "Hello World!"
Expected results
Hello World!
Actual results
Hello <b>World</b>!
Diagnostics
Lack of contentType in JSON data sent to O365
CLI for Microsoft 365 version
"v10.0.0"
nodejs version
v18.19.0
Operating system (environment)
Linux
Shell
bash
cli doctor
Additional Info
No response
The text was updated successfully, but these errors were encountered: