0

I have an Outlook App that works OK, using an ErrorMessage, but I want to try InsightMessage and associated actions, but no luck - so far; the only good source of information I could find was Learn.Microsoft

I've also seen this related(?) issue on Stack Overflow

I'm trying to implement something like Viva, see screenshot, where there's a message which includes an action, like a link enter image description here

The App runs but "nothing happens" - I can log the value of "result", which shows an error but there is no detail

The relevant code snippet is

Office.context.mailbox.item.notificationMessages.replaceAsync("messageKey", {
    type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
    message: email.Notification.Message,
    icon: 'TeamsAssistLogo64x64',
    actions: [{
        actionText: 'Open insight',
        actionType: Office.MailboxEnums.ActionType.ShowTaskPane,
        commandId: 'msgReadOpenPaneButton',
        contextData: JSON.stringify({ a: 'aValue', b: 'bValue' })
    }]
})

Notes / Issues

  1. I don't really see how the App can identify another (Taskpane) App?
  2. TeamsAssistLogo64x64 (.png) is defined in the Taskpane Manifest
  3. I'm not sure about msgReadOpenPaneButton; the Taskpane Manifest contains <Control xsi:type="Button" id="msgReadOpenPaneButton">; I don't know if that's right

On-Send Manifest

  <?xml version="1.0" encoding="utf-8"?>
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->

<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>20bbdabc-cb35-442f-9965-28a6099b25c4</Id>

<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>3.16.2.1</Version>
<ProviderName>TeamsAssist</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="TeamsAssist Notifications" />
<Description DefaultValue="TeamsAssist OnSend Notifications" />
<IconUrl DefaultValue="https://teamsassistoutlookonsend.azurewebsites.net/Images/TeamsAssistLogo64x64.png" />
<HighResolutionIconUrl DefaultValue="https://teamsassistoutlookonsend.azurewebsites.net/Images/TeamsAssistLogo128x128.png" />

<SupportUrl DefaultValue="https://cloudassist.co/" />   

<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
  <AppDomain>https://teamsassistoutlookserver.azurewebsites.net</AppDomain>
  <AppDomain>https://teamsassistoutlooktaskpane.azurewebsites.net</AppDomain>     
</AppDomains>
<!--End Basic Settings. -->

<Hosts>
  <Host Name="Mailbox" />
</Hosts>
<Requirements>
  <Sets>
    <Set Name="Mailbox" MinVersion="1.1" />
  </Sets>
</Requirements>
<FormSettings>
  <Form xsi:type="ItemRead">
    <DesktopSettings>
  <SourceLocation DefaultValue="https://teamsassistoutlookonsend.azurewebsites.net/index.html?serverURL=https://teamsassistoutlookserver.azurewebsites.net/" />
      <RequestedHeight>250</RequestedHeight>
    </DesktopSettings>
  </Form>
</FormSettings>

<Permissions>ReadWriteItem</Permissions>

<Rule xsi:type="RuleCollection" Mode="Or">
  <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" />     
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>

<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
  <!-- On Send requires VersionOverridesV1_1 -->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
  <Description resid="residAppDescription" />
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
    <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <!-- The functionfile and function name to call on message send.  -->
          <!-- In this particular case the function validateEmail will be called within the JavaScript code referenced in residUILessFunctionFileUrl. -->
          <FunctionFile resid="residUILessFunctionFileUrl" />
          <ExtensionPoint xsi:type="Events">
            <Event Type="ItemSend" FunctionExecution="asynchronous" FunctionName="validateEmail" />
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Urls>
        <!-- The JavaScript code is hosted on a secure and trusted web server. -->
        <bt:Url id="residUILessFunctionFileUrl" DefaultValue="https://teamsassistoutlookonsend.azurewebsites.net/index.html?serverURL=https://teamsassistoutlookserver.azurewebsites.net/"></bt:Url>
      </bt:Urls>
    </Resources>
  </VersionOverrides>
</VersionOverrides>
JohnD
  • 187
  • 11
  • Is the task pane displayed when you click on the ribbon button? – Eugene Astafiev Apr 04 '23 at 20:58
  • The `replaceAsync` method accepts the third parameter which stands for the callback invoked when the notification item is added or failed. Have you checked the results whether it was successful? – Eugene Astafiev Apr 05 '23 at 13:24

2 Answers2

1

I can answer my own question now: the issue is that the Insight Message, that I want to implement is implemented in a (fairly) new feature called Smart Alerts, described here

As documented in there, for an existing App, like our own, this requires a substantial modification of the Manifest; and not just that, to ensure the updated Manifest is still valid, I had also to update the XSD file

It is also necessary to update the "On-Send" to use the (new) Message Type, of InsightMessage

JohnD
  • 187
  • 11
0

To associate the the notification item action with a task pane you specify the commandId property which corresponds to the ribbon button used to open the task pane. For example, you can find the following piece of markup in the manifest file:

<Control xsi:type="Button" id="msgReadOpenPaneButton">
   <Label resid="TaskpaneButton.Label"/>
   <Supertip>
     <Title resid="TaskpaneButton.Label"/>
     <Description resid="TaskpaneButton.Tooltip"/>
   </Supertip>
   <Icon>
     <bt:Image size="16" resid="Icon.16x16"/>
     <bt:Image size="32" resid="Icon.32x32"/>
     <bt:Image size="80" resid="Icon.80x80"/>
   </Icon>
   <Action xsi:type="ShowTaskpane">
     <SourceLocation resid="Taskpane.Url"/>
   </Action>
</Control>

You can find the Action element which tells that a ribbon button is used to open a task pane specified by the URL (see the SourceLocation element).

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks, commandId understood; but I must have something wrong as action does not occur; is there any sample I can refer to? I'm not using contextData – JohnD Apr 05 '23 at 11:11
  • The code is straightforward and the `contextData` property is optional. The `replaceAsync` method accepts the third parameter which stands for the callback invoked when the notification item is added or failed. Have you checked the results whether it was successful? – Eugene Astafiev Apr 05 '23 at 13:25
  • I added a screenshot, to clarify what I'm trying to do; yes, the Callback works fine but the "result" status is "failed"; the "value" is undefined, and I don't know the reason. How do I define an "actionable" message like the screenshot? Part of the issue surely must be how does the OnSend App identify the Taskpane App? I can see commandId identifies the place in the App, but how is the App itself known? – JohnD Apr 06 '23 at 08:18
  • Dug a little more to find out about error, as follows: OSF.DDA.Error {name: 'InvalidParameterValueError', message: "The value of the '{0}' parameter is invalid.", code: 9031 – JohnD Apr 06 '23 at 09:11
  • Only one notification of type `InsightMessage` is allowed per add-in. Attempting to add more will throw an error. Also try to play with parameters by removing unnecessary things. As soon as you get the notification item displayed in Outlook you may configure it as required. – Eugene Astafiev Apr 06 '23 at 13:02
  • Have you tried to remove the `contextData` from the payload? – Eugene Astafiev Apr 06 '23 at 13:03
  • Yes, contextData commented out; can you please explain how the OnSend App can identify the Taskpane app (I understand that msgReadOpenPaneButton gives the entry point) but since there could be several Taskpane Apps deployed how does it know which one to invoke? – JohnD Apr 07 '23 at 11:43
  • The task pane is refenced by the web page associated in the manifest file. The `msgReadOpenPaneButton` command should be used to open a task pane in the manifest. – Eugene Astafiev Apr 09 '23 at 17:07
  • All makes sense, but still can't get it to show the message; I suspect the "icon" element: am I right in supposing it should be defined as the "resid" for the Icon in the Taskpane Manifest and that the Taskpane App is itself defined in the On-Send Manifest as an AppDomain - to allow navigation to it??? – JohnD Apr 12 '23 at 16:35
  • I'd suggest posting the manifest file, so we could check all things. – Eugene Astafiev Apr 12 '23 at 21:50
  • Done; note: Apps work fine - prior to current efforts to implement InsightMessage – JohnD Apr 13 '23 at 08:15