cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jmann223
New Member

Teams Chat to OneNote

I have created a Flow using the default template "Save a message to OneNote" and that works perfectly.  The issue I am having is that I would like to modify the content that is dumped into OneNote.

 

Specifically, I would like the automation to post the Date/Time stamp of the Teams Message being "saved" into the OneNote note body.  I cannot see a way to do this with the Dynamic Content, maybe there is a way to do this with expressions?  Right now, my "hack" is to manually add this into the"myNote" popup when triggering the automation.

 

Here is the Flow's OneNote "Create a page in a section" code config:

{
    "inputs": {
        "host": {
            "connectionName""shared_onenote",
            "operationId""CreatePageInSection",
            "apiId""/providers/Microsoft.PowerApps/apis/shared_onenote"
        },
        "parameters": {
            "notebookKey":REDACTED,
            "sectionId": REDACTED,
            "pageContent""<html><head><title>Message from @{triggerBody()?['teamsFlowRunContext']?['messagePayload']?['from']?['user']?['displayName']}</title></head><body><p>Message from @{triggerBody()?['teamsFlowRunContext']?['messagePayload']?['from']?['user']?['displayName']} saved from Teams<br><br>Message details: <br>MessageID=@{triggerBody()?['teamsFlowRunContext']?['messagePayload']?['id']}<br>@{triggerBody()?['teamsFlowRunContext']?['messagePayload']?['body']?['content']}<br><br><br>Notes:<br>@{triggerBody()?['cardOutputs']?['myNote']}<br><br><a href=\"@{triggerBody()?['teamsFlowRunContext']?['messagePayload']?['linkToMessage']}\">Link to message</a></p></body></html>"
        },
        "authentication": {
            "type""Raw",
            "value""@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"
        }
    },
    "metadata": {
        "operationMetadataId""983f0072-de7f-4a40-885a-65155b67042f"
    }
}
1 ACCEPTED SOLUTION

Accepted Solutions
v-liwei-msft
Microsoft
Microsoft

Hi @Jmann223 ,

 

As you can see, the time the message is inserted into OneNote does not exist in the dynamic content. 
But this time can be obtained:
vliweimsft_0-1658822686472.png

 

You can enter this formula in Expression to get the time: 
triggerOutputs()['headers']['x-ms-user-timestamp']
vliweimsft_1-1658822735031.jpeg

 

 

Best Regards,

Levi

 

View solution in original post

3 REPLIES 3
v-liwei-msft
Microsoft
Microsoft

Hi @Jmann223 ,

 

As you can see, the time the message is inserted into OneNote does not exist in the dynamic content. 
But this time can be obtained:
vliweimsft_0-1658822686472.png

 

You can enter this formula in Expression to get the time: 
triggerOutputs()['headers']['x-ms-user-timestamp']
vliweimsft_1-1658822735031.jpeg

 

 

Best Regards,

Levi

 

Levi,

 

Thanks for the assistance! There does seem to be an issue still even after adding in this expression.

 

It appears that the date/timestamp that is added is the current date/time when I click "more options > Send a copy of this to OneNote"

For example just 10 min ago I ran it on this chat:
blurneeded.png

 

Notice it was Yesterday (7/27) at 7:08pm (eastern time), however the output to my onenote shows the current date and time:

onenote.png

 

 

So essentially I still have two challenges I need assistance with:

  1. How can I get the date displayed next to the red arrow display the date of when the teams message was sent not the date when I click save to onenote.
  2. How can I modify the output to display something that is slightly easier to read at a glance.
    • Ideally this would be MM-DD-YYYY HH:MM:SS format, displayed in my time zone (eastern time) instead of GMT as it is currently being displayed in.

 

Thanks!

v-liwei-msft
Microsoft
Microsoft

Hi @Jmann223 ,

 

For a selected message, the trigger does not return the time the message was sent. 

Sorry for the inconvenience caused. 

If you want to change the timezone and date format, I recommend you to use the function:

convertTimeZone('<timestamp>', '<sourceTimeZone>', '<destinationTimeZone>', '<format>'?)

I think this link will help you a lot:

Reference guide for expression functions - Azure Logic Apps | Microsoft Docs

 

Best Regards,

Levi

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,164)