Teams bot dev: access the original formatted user input in Activity payload
Hello,
How can I access the original user input content from inside the Activity payload?
Until now, I used to look at the Activity.attachments where the contentType is "text/html" and it should be the original message.
When I have a payload coming from iOS, the message is not always in the Activity.attachments
It looks like it's only there when there is more than one line of text.
Also, the HTML content is not the same on iOS and Desktop, which is a bad thing to parse it and understand its content.
How can I access the raw formatted user input every time?
Thanks
Microsoft Teams Development
-
Sayali-MSFT 2,416 Reputation points • Microsoft Vendor
2023-07-03T06:49:38.3166667+00:00 @Benoit Dupont -Thanks for reporting your issue.
Could you please elaborate your requirement and share the repro steps or code snippets, so that we can try it from our end.
-
Sayali-MSFT 2,416 Reputation points • Microsoft Vendor
2023-07-05T09:11:29.1266667+00:00 @Benoit Dupont - Please have look into this document-https://video2.skills-academy.com/en-us/microsoftteams/platform/bots/how-to/format-your-bot-messages#support-by-individual-platform
2.https://video2.skills-academy.com/en-us/microsoftteams/platform/bots/how-to/conversations/conversation-messages?tabs=dotnet1%2Cdotnet2%2Cdotnet3%2Cdotnet4%2Cdotnet5%2CdotnetIf possible, could you please share code snippets so that we can try it from our end?
-
Benoit Dupont 66 Reputation points
2023-07-05T11:52:17.99+00:00 So this is a sample payload from Teams Desktop.
{ "text": "this is a sample text from Teams Desktop", "textFormat": "plain", "attachments": [ { "contentType": "text/html", "content": "<p>this is a sample text from Teams Desktop</p>" } ], "type": "message", "timestamp": "2023-07-05T11:44:42.6749097Z", "localTimestamp": "2023-07-05T08:44:42.6749097-03:00", "id": "1688557482659", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/amer/", "from": { "id": "29:1JiEH1nLmzqH5YT7Do_1KRCs7ISDxUmVVKPbIzwM1pc884QpFbzi7GFznE58JZKe5sdjw65yzjAZtxyJt55B3mA", "name": "Benoit Dupont", "aadObjectId": "af24b8a2-cfe8-453a-a9b4-4a917b1534ae" }, "conversation": { "conversationType": "personal", "tenantId": "caafef10-9d12-4668-a0d6-268b71695e1a", "id": "a:1ktMfOkUqtyhd4ub9GhZwaOdqpjjygWz5IZGvHZLTCnduBU1HmsFGO9vBAMZMQhqJOeiphjhE_k9G3HerhrBgeIf6uuA-FYRX93w_OsJYVTFX1lB36Q5xJgAGJtizZM1o" }, "recipient": { "id": "28:45fc30f1-94c5-48aa-b0df-ef0e41b65c6c", "name": "XM Fax US " }, "entities": [ { "locale": "en-US", "country": "US", "platform": "Web", "timezone": "America/Halifax", "type": "clientInfo" } ], "channelData": { "tenant": { "id": "caafef10-9d12-4668-a0d6-268b71695e1a" } }, "locale": "en-US", "localTimezone": "America/Halifax" }
And this is from iOS
{ "text": "This is a sample text from iOS", "textFormat": "plain", "type": "message", "timestamp": "2023-07-05T11:45:32.5030988Z", "localTimestamp": "2023-07-05T08:45:32.5030988-03:00", "id": "1688557532489", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/amer/", "from": { "id": "29:1JiEH1nLmzqH5YT7Do_1KRCs7ISDxUmVVKPbIzwM1pc884QpFbzi7GFznE58JZKe5sdjw65yzjAZtxyJt55B3mA", "name": "Benoit Dupont", "aadObjectId": "af24b8a2-cfe8-453a-a9b4-4a917b1534ae" }, "conversation": { "conversationType": "personal", "tenantId": "caafef10-9d12-4668-a0d6-268b71695e1a", "id": "a:1ktMfOkUqtyhd4ub9GhZwaOdqpjjygWz5IZGvHZLTCnduBU1HmsFGO9vBAMZMQhqJOeiphjhE_k9G3HerhrBgeIf6uuA-FYRX93w_OsJYVTFX1lB36Q5xJgAGJtizZM1o" }, "recipient": { "id": "28:45fc30f1-94c5-48aa-b0df-ef0e41b65c6c", "name": "XM Fax US " }, "entities": [ { "locale": "en-US", "country": "BE", "platform": "iOS", "timezone": "America/Moncton", "type": "clientInfo" } ], "channelData": { "tenant": { "id": "caafef10-9d12-4668-a0d6-268b71695e1a" } }, "locale": "en-US", "localTimezone": "America/Moncton" }
As you can see, the attachment with the HTML version is not available in the payload of the iOS version.
Now, if you make text on two lines, you have the HTML attachment from the iOS payload too. But the HTML from the iOS version and Destop version are not structured the same. Desktop is using <p> tags when iOS is using a <div> with <br>.
Decomposing the HTML is harder because it's not the same depending on the platform.
{ "text": "This is Desktop on two lines\r\nsecond line", "textFormat": "plain", "attachments": [ { "contentType": "text/html", "content": "<p>This is Desktop on two lines</p>\r\n<p>second line</p>" } ], "type": "message", "timestamp": "2023-07-05T11:48:06.9054282Z", "localTimestamp": "2023-07-05T08:48:06.9054282-03:00", "id": "1688557686892", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/amer/", "from": { "id": "29:1JiEH1nLmzqH5YT7Do_1KRCs7ISDxUmVVKPbIzwM1pc884QpFbzi7GFznE58JZKe5sdjw65yzjAZtxyJt55B3mA", "name": "Benoit Dupont", "aadObjectId": "af24b8a2-cfe8-453a-a9b4-4a917b1534ae" }, "conversation": { "conversationType": "personal", "tenantId": "caafef10-9d12-4668-a0d6-268b71695e1a", "id": "a:1ktMfOkUqtyhd4ub9GhZwaOdqpjjygWz5IZGvHZLTCnduBU1HmsFGO9vBAMZMQhqJOeiphjhE_k9G3HerhrBgeIf6uuA-FYRX93w_OsJYVTFX1lB36Q5xJgAGJtizZM1o" }, "recipient": { "id": "28:45fc30f1-94c5-48aa-b0df-ef0e41b65c6c", "name": "XM Fax US " }, "entities": [ { "locale": "en-US", "country": "US", "platform": "Web", "timezone": "America/Halifax", "type": "clientInfo" } ], "channelData": { "tenant": { "id": "caafef10-9d12-4668-a0d6-268b71695e1a" } }, "locale": "en-US", "localTimezone": "America/Halifax" }
{ "text": "This is iOS on two lines \r\nSecond line", "textFormat": "plain", "attachments": [ { "contentType": "text/html", "content": "<div>This is iOS on two lines <br>\r\nSecond line</div>" } ], "type": "message", "timestamp": "2023-07-05T11:48:31.8864395Z", "localTimestamp": "2023-07-05T08:48:31.8864395-03:00", "id": "1688557711871", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/amer/", "from": { "id": "29:1JiEH1nLmzqH5YT7Do_1KRCs7ISDxUmVVKPbIzwM1pc884QpFbzi7GFznE58JZKe5sdjw65yzjAZtxyJt55B3mA", "name": "Benoit Dupont", "aadObjectId": "af24b8a2-cfe8-453a-a9b4-4a917b1534ae" }, "conversation": { "conversationType": "personal", "tenantId": "caafef10-9d12-4668-a0d6-268b71695e1a", "id": "a:1ktMfOkUqtyhd4ub9GhZwaOdqpjjygWz5IZGvHZLTCnduBU1HmsFGO9vBAMZMQhqJOeiphjhE_k9G3HerhrBgeIf6uuA-FYRX93w_OsJYVTFX1lB36Q5xJgAGJtizZM1o" }, "recipient": { "id": "28:45fc30f1-94c5-48aa-b0df-ef0e41b65c6c", "name": "XM Fax US " }, "entities": [ { "locale": "en-US", "country": "BE", "platform": "iOS", "timezone": "America/Moncton", "type": "clientInfo" } ], "channelData": { "tenant": { "id": "caafef10-9d12-4668-a0d6-268b71695e1a" } }, "locale": "en-US", "localTimezone": "America/Moncton" }
-
Sayali-MSFT 2,416 Reputation points • Microsoft Vendor
2023-07-06T11:20:48.14+00:00 @Benoit Dupont-Thanks for providing information. We will check it from our end and get back to you.
-
Nivedipa-MSFT 3,021 Reputation points • Microsoft Vendor
2024-09-27T07:06:59.29+00:00 @Benoit Dupont - We have raised a bug for the same, We will let you know once we get any updates on it.
Sign in to comment