Get text of most recent notification with applescript
Using the following example AppleScript code to generate a notification:
display notification with title &quot;Macro Cancelled&quot; subtitle &quot;Cancel All Macros.&quot;

In the example notification, Cancel All Macros. is in:
static text of scroll area 1 of window 1 of process &quot;NotificationCenter&quot;

Using:
tell application &quot;System Events&quot; to ¬
    get value of ¬
        static text of ¬
        scroll area 1 of ¬
        window 1 of ¬
        process &quot;NotificationCenter&quot;

It returns:
{&quot;Cancel All Macros.&quot;, &quot;&quot;}

As you can see what's returned is a list and will need to be process as such.
Note however, in this example, Cancel All Macros. is actually static text 1 of scroll area 1 and static text 2 of scroll area 1, which is blank, is when display notification uses:

display notification [text] : the body text of the notification


Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

With Error Handling:
tell application &quot;System Events&quot; to ¬
    if exists window 1 of ¬
        process &quot;Notification Center&quot; then ¬
        get value of ¬
            static text of ¬
            scroll area 1 of ¬
            window 1 of ¬
            process &quot;NotificationCenter&quot;