This article provides information on how to build the Pega Sales Automation Teams embedded app when using the Constellation architecture.
Creating Teams Splash Screen Servlet
- Get access to the server by using PuTTY or WinSCP.
- Navigate to the location of web.xml file, and open it for editing.
- Search for the first
<servlet>
tag, and then insert the following XML snippet:
<servlet>
<servlet-name>TeamsMeetingSplash</servlet-name>
<display-name>TeamsMeetingSplash</display-name>
<description>Teams Meeting Splash</description>
<servlet-class>com.pega.pegarules.internal.web.servlet.WebStandardBoot</servlet-class>
<init-param>
<param-name>PegaEtierClass</param-name>
<param-value>com.pega.pegarules.session.internal.engineinterface.service.HttpAPI</param-value>
</init-param>
<init-param>
<param-name>AuthenticationType</param-name>
<param-value>PRCustom</param-value>
</init-param>
<init-param>
<param-name>RuntimeServletName</param-name>
<param-value>TeamsMeetingSplash</param-value>
</init-param>
<init-param>
<param-name>AuthService</param-name>
<param-value>TeamsMeetingSplash</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>TeamsMeetingSplash</servlet-name>
<url-pattern>/TeamsMeetingSplash</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TeamsMeetingSplash</servlet-name>
<url-pattern>/TeamsMeetingSplash/*</url-pattern>
</servlet-mapping> - Save the file.
- Restart the server.
Creating Teams meeting app
- Enable a custom app for the organization in Teams:
- Log in to the Microsoft Teams admin center at https://admin.teams.microsoft.com/.
- On the left navigation pane, under Teams apps, click Manage apps.
- In the Actions list, click Org-wide app settings.
- In the Custom apps section, turn on the Let users install and use available apps by default and Let users interact with custom apps in preview settings.
- Save your changes.
- Sign in to Teams at https://teams.microsoft.com/v2/.
- In the left navigation pane, click Apps.
- Search for the Developer Portal app, and then open it.
This app enables you to build a custom app. - On the Apps tab, click New app.
- Enter a name for your Teams app.
- Leave the manifest version as the latest version, and click Add.
The new app's configuration screen opens. - On the Basic Information tab (which is under Configure but opens by default when you add a new app), complete the following fields, and then click Save:
- Short name
- Long description
- Developer or company name
- Website
- Privacy policy (URL)
- Terms of use
- On the App features tab, click Group and channel app, enter the following details, and then click Save:
- In the Configuration URL field, enter the Login URL from the TeamsMeetingSplash Authentication Service Rule.
You can find this Rule in Dev Studio, under Records > SysAdmin > Authentication Service. - In the Scope section, select the Team and Group chat checkboxes.
- In the Context field, add meetingSidePanel.
This setting is required so that the meeting app displays in the side panel.
- In the Configuration URL field, enter the Login URL from the TeamsMeetingSplash Authentication Service Rule.
- Under Configure > Domains, add all the domains for the app to give access to load in Teams:
For example:
staging-cdn.constellation.pega.io
prod.constellation.pega.io
pega.com
linkedin.com
fonts.googleapis.com
www.linkedin.com
maps.googleapis.com
sa-cdn.constellation.pega.io
fonts.gstatic.com
staging.constellation.pega.io
staging2.constellation.pega.io
teams.cloud.microsoft
m365.cloud.microsoft
- Click Advanced > Owners, and Add any additional owners to manage the app.
- Publish the app for use in any of the following ways:
- Download the app package and distribute it to an individual.
You can do this by clicking Publish > Publish to store, and then clicking the Download app package button. Use this method during development. - Publish the app to everyone in the organization.
You can do this by clicking Publish > Publish to org.
This action requires the admin of your organization to approve. - When satisfied with the quality and content of the app, publish the app to the market for everyone to use.
This action requires a dedicated server for the app to access, and an approval from Microsoft.
- Download the app package and distribute it to an individual.
Creating the app registration
- In Microsoft Azure portal, open the Entra ID service.
- Click Manage > App Registrations.
- On the App Registration landing page, click New Registration.
- Enter the name of the app registration.
- Leave the Support account type radio button defaulted to Accounts in this organization.
- In the Redirect URI platform list, select Web.
- Enter the redirect URI.
- Click Register.
- Under the Application (client) ID heading, click the Copy to clipboard icon next to the client ID, and save it for a later step.
- Navigate to Manage > API permissions.
- Click Add a permission.
- Click the Microsoft APIs tab.
- Click Microsoft Graph.
- Select all the necessary permissions for the app.
- Click Add permissions.
- Navigate to Manage > Certificates & secrets.
- On the Client secrets tab, click New client secret.
- Enter a description for the client secret.
- Click Add.
- In the table of client secrets, click the Copy to clipboard icon for the newly client secret, and save it for a later step.
Enabling Teams meeting app in Sales Automation
- In Dev Studio, configure the requestor type:
- In Dev Studio, click Records > SysAdmin > Requestor Type, and find the BROWSER requestor type for your system.
- Add an entry to the Access Group Name field by clicking the Add icon.
- Enter your application’s unauthenticated Access Group.
- Default the newly entered Access Group by selecting the radio button associated with it.
- Save your changes.
- Enable the Teams servlet:
- Search for the MeetingAppTeamsC11nService Authentication Service Rule.
You can also navigate to this rule from Records > SysAdmin > Authentication Service. - Select the Enable this authentication service checkbox.
- Save your changes.
- Search for the MeetingAppTeamsC11nService Authentication Service Rule.
- Add the Teams meeting app portal to the Access Group of your sales representatives:
- In Dev Studio, click Records > Security > Access Group, and open the SalesAutomation-Constellation:SalesRep Access Group.
- Click Add portal.
- Select MeetingAppCondensePortal.
- Save your changes.
- Update the Teams meeting app portal for a login redirect:
- In Dev Studio, click Records > Technical > Activity, and find the MeetingAppRedirect activity.
- Save the activity to an open Ruleset or branch.
- Check out the Rule.
- Expand the Property-Set Step, and update the local.portal property value to MeetingAppCondensePortal.
- Save your changes.
- Update the cross-browser settings:
- In Dev Studio, click Configure > Systems > Settings > Cross-Site Requestor Forgery.
- In the Cookies Settings section, select the Enable samesite cookie attribute checkbox.
- In the Samesite Options list, select None.
- Enable the CreateSubscriptionForMSTeams job scheduler:
- In Dev Studio, click Records > SysAdmin > Job Scheduler.
- Search for the CreateSubscriptionForMSTeams job scheduler.
- Save the job scheduler to an open ruleset or branch.
- Enable the job scheduler.
- Save or check in your changes.
- Set up a keystore:
- In Dev Studio, click Records > Security > Keystore, and then locate the MSTeams rule.
- Update the Rule with the information from your keystore.
For more information, see Example of creating a keystore and generating a certificate key below. - In the global search, search for the GetMeetingAppTeamsSettings Data Transform.
- Save the Data Transform to an open ruleset.
- Update Step 2 of the Data Transform with the certificate key value that you obtained when exporting the certificate by using base64 encoding.
For more information, see Example of creating a keystore and generating a certificate key below. - Save your changes.
- Update the MSTeamsClientCode Authentication Profile:
- In Dev Studio, click Records > Security > Authentication Profile, and then open the MSTeamsClientCode Authentication Profile.
- Enter or paste the client identifier from step 9 in Creating the app registration above.
- Enter or paste the client secret from step 20 in Creating the app registration above.
- Save your changes.
- Update the MSTeamsAuthCode Authentication Profile:
- In Dev Studio, click Records > Security > Authentication Profile, and then locate the MSTeamsAuthCode Rule.
- Enter or paste the client identifier from step 9 in Creating the app registration above.
- Enter or paste the client secret from step 20 in Creating the app registration above.
- Save your changes.
Additional configuration for Mac users
- Update your Application Rule’s definition:
- In the Dev Studio header, click your application name, and then click Definition.
- Click the Security tab.
- In the Contect security section, set the policy name to pxDefaultAllowAll.
- Set the Mode radio button to Reject and report.
- Update the dynamic system setting (DSS):
- In Dev Studio, click Records > SysAdmin > Dynamic System Settings.
- Locate the http/responseHeaders DSS for the owning ruleset Pega-RulesEngine.
- Update the DSS value to the following:
{"X-Content-Type-Options":"nosniff","X-XSS-Protection":"1","Referrer-Policy":"no-referrer","Strict-Transport-Security":"max-age=31536000"}
Adding the Sales Automation meeting app to Teams
Each member of the sales team must perform these steps:
- While in a Teams meeting, click Apps in the top navigation.
- Search for your Sales Automation meeting app.
- Double-click the app to add it as a tab on the top navigation.
- Optional: If the Sales Automation meeting app is not available, you can import it by clicking Manage apps.
- Click Save.
Extending the Teams meeting app
When the Teams meeting app runs, Pega Sales Automation sees that the requests are coming in from a specific URL. This URL is the Teams servlet url. The Teams servlet url is mapped to the MeetingAppTeamsSplah Authentication Rule. This rule renders the HTML code to display the content of the modal when adding an app from Teams. When a user clicks Save in that modal, the Teams app redirects to the Pega Sales Automation login screen. This redirect hits a new servlet by using the MeetingAppTeamsServiceC11n Authentication Service Rule.
The MeetingAppTeamsServiceC11n Authentication Service Rule has a post activity, MeetingAppLogin, that redirects to an activity called MeetingAppRedirect. This activity switches the portal of the current user to their secondary portal, MeetingAppCondensePortal. Because of the new portal, Pega Sales Automation can identify the correct rules to display for the Teams meeting app.
The portal loads the following custom react components:
- MeetingApp: This component loads the Teams SDK, gets all the information about the meeting from Teams, and provides all the necessary setup to run the Teams meeting app in Pega Sales Automation.
- SAIntelligence and ConversationalAI: These components load the Voice AI feature to suggest Cases and knowledge articles in the Teams meeting app.
Each card in the Attendees and Overview sections is rendered by using a custom React component called GenericSummaryList, in the form of a widget. You can add this widget to any view and customize it from App Studio. There is also a Knowledge Section containing a widget called Knowledge, which displays knowledge articles, including suggested articles.
Teams events
With the Teams meeting app running, every time something happens in Teams, the system sends a notification, called a Change Notification, to the meeting app. The meeting app then sends the notification to the endpoint URL. For example, when a participant joins, the meeting app sends a Microsoft.Communication.CallRosterUpdate event to Pega Sales Automation.
Pega Sales Automation includes a REST service, MeetingAppEvents, which calls an activity called ProcessEvents. For Teams, this activity tries to match the event and call the right activity to run to handle the event. For the Microsoft.Communication.CallStarted event, the ProcessEvents activity creates an appointment if it doesn’t exist, and creates a meetinginfo instance to save the meeting with the New status. For participants joining or leaving events (Microsoft.Communication.CallRosterUpdate), the ProcessEvents activity updates the meetingparticipant table with the corresponding status. For the Microsoft.Communication.CallEnded event, it updates the meetinginfo Rule with the Resolved status. It then loops through all the participants in the meeting and updates their status as left in the meetingparticipant table.
After an event is processed, Pega Sales Automation sends a notification to the UI to refresh changes using the pub-sub architecture through the Pega Constellation messaging service. For more information, see the Constellation messaging service documentation.
Change notifications require the creation of a subscription. The system creates the subscription by using the D_CreateSubscriptionForMSTeams Data Page, when the Teams virtual meeting is created while setting up an appointment in Pega Sales Automation. By default, the subscription expires in 3 days. If the appointment is after 3 days, the system does not send the notification. A job scheduler handles this scenario, by running daily, getting the Teams appointments schedule for the day, looping through all the appointments, and creating a subscription for those appointments.
MeetingApp component
The Teams meeting app is its own Pega application component called MeetingApp. You can place this component in any application, in the Component section. Being its own component, the Teams meeting app is not tied exclusively to Pega Sales Automation. You can make it available in Pega Customer Service or any other customer application. The MeetingApp app's class structure is under the base class PegaFW-. It is placed under this class so that these rules are available to any framework due to the generic class structure, and you can add Teams to any application in the future.
In thePegaFW- class, Teams has two class structures through the subclass MeetingApp, which is present under the PegaFW-Int- and PegaFW-Data- classes. The MeetingApp subclass groups the functionality for all the meeting apps such as Zoom, WebEx, and Microsoft Teams into one central place. Teams has a subclass of its own under this subclass.
The PegaFW-Int-MeetingApp class handles the integration from Pega to any external system that Pega needs to interact with. It has all the class structure that is required to handle the JSON data model for the events that are exchanged between Pega Sales Automation and external systems.
The PegaFW-Data-MeetingApp class handles the meeting functionality for any meeting app that Pega supports. It tracks the meeting object, PegaFW-Data-MeetingApp-MeetingInfo, and the participants list for the meeting, PegaFW-Data-MeetingApp-Participants.
The rules used for the MeetingApp component are included in the PegaFW-MeetingApp Ruleset. This Ruleset is generic and might not do much until you specialize it to your application. Therefore, for any specific functionality that you want to add to the Pega Sales Automation application built with Constellation, the generic rules are saved into the PegaSA-DataTier or PegaSA-CaseTier Rulesets and are specialized. For example, if you want to add a Data Page, D_GetAttendeesNotYetJoined, save it to the PegaSA-DataTier Ruleset, and update the class to be Common-LDM-Entity-Contact (because this is the class that represents a person), then you must specialize the Data Transform as well to indicate how to get the attendees information into your application. For example, in Pega Sales Automation, the system gets the attendees information from the class associated with appointments.
Appendix
Sample permissions to add to the app
Microsoft Graph (33) |
||||
Calendars.Read |
Application |
Read calendars in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Calendars.ReadBasic.All |
Application |
Read basic details of calendars in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Calendars.ReadWrite |
Application |
Read and write calendars in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Chat.Create |
Application |
Create chats |
Yes |
Granted for PEGASYSTEMS INC |
Chat.Read |
Delegated |
Read user chat messages |
No |
Granted for PEGASYSTEMS INC |
Chat.Read.All |
Application |
Read all chat messages |
Yes |
Granted for PEGASYSTEMS INC |
Chat.ReadBasic |
Delegated |
Read names and members of user chat threads |
No |
Granted for PEGASYSTEMS INC |
Chat.ReadBasic.All |
Application |
Read names and members of all chat threads |
Yes |
Granted for PEGASYSTEMS INC |
Chat.ReadWrite |
Delegated |
Read and write user chat messages |
No |
Granted for PEGASYSTEMS INC |
Chat.ReadWrite.All |
Delegated |
Read and write all chat messages |
Yes |
Granted for PEGASYSTEMS INC |
Chat.ReadWrite.All |
Application |
Read and write all chat messages |
Yes |
Granted for PEGASYSTEMS INC |
ChatMessage.Read |
Delegated |
Read user chat messages |
No |
Granted for PEGASYSTEMS INC |
Group.Create |
Application |
Create groups |
Yes |
Granted for PEGASYSTEMS INC |
Group.Read.All |
Application |
Read all groups |
Yes |
Granted for PEGASYSTEMS INC |
Group.ReadWrite.All |
Application |
Read and write all groups |
Yes |
Granted for PEGASYSTEMS INC |
Mail.Read |
Application |
Read mail in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Mail.ReadBasic |
Application |
Read basic mail in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Mail.ReadBasic.All |
Application |
Read basic mail in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Mail.ReadWrite |
Application |
Read and write mail in all mailboxes |
Yes |
Granted for PEGASYSTEMS INC |
Mail.Send |
Application |
Send mail as any user |
Yes |
Granted for PEGASYSTEMS INC |
OnlineMeetings.Read |
Delegated |
Read user's online meetings |
No |
Granted for PEGASYSTEMS INC |
OnlineMeetings.Read.All |
Application |
Read online meeting details |
Yes |
Granted for PEGASYSTEMS INC |
OnlineMeetings.ReadWrite |
Delegated |
Read and create user's online meetings |
No |
Granted for PEGASYSTEMS INC |
OnlineMeetings.ReadWrite.All |
Application |
Read and create online meetings |
Yes |
Granted for PEGASYSTEMS INC |
Presence.Read |
Delegated |
Read user's presence information |
No |
Granted for PEGASYSTEMS INC |
Presence.Read.All |
Delegated |
Read presence information of all users in your organization |
No |
Granted for PEGASYSTEMS INC |
TeamSettings.Read.All |
Application |
Read all teams' settings |
Yes |
Granted for PEGASYSTEMS INC |
TeamSettings.ReadWrite.All |
Application |
Read and change all teams' settings |
Yes |
Granted for PEGASYSTEMS INC |
User.Read |
Delegated |
Sign in and read user profile |
No |
Granted for PEGASYSTEMS INC |
User.Read.All |
Delegated |
Read all users' full profiles |
Yes |
Granted for PEGASYSTEMS INC |
User.Read.All |
Application |
Read all users' full profiles |
Yes |
Granted for PEGASYSTEMS INC |
User.ReadBasic.All |
Delegated |
Read all users' basic profiles |
No |
Granted for PEGASYSTEMS INC |
User.ReadWrite.All |
Application |
Read and write all users' full profiles |
Yes |
Granted for PEGASYSTEMS INC |
Example of creating a keystore and generating a certificate key
- Download KeyStore Explorer (freeware).
- Open KeyStore Explorer.
- Click Create a new KeyStore icon.
- Keep the default PKCS #12, and click OK.
- Click Tools > Generate Key Pair.
- Keep the default RSA Key Size 2048, and click OK.
- Keep the default, and click the Edit Name icon next to the Name field.
- In the Common Name (CN) field, enter Pega.
- In the Organization Unit (OU) field, enter Sales Automation.
- In the Organization Name (O) field, enter Pegasystems, Inc.
- In the Locality Name (L) field, enter Waltham.
- In the State Name (ST) field, enter MA.
- In the Country (S) field, enter USA.
- Click OK.
- Click OK
- Enter the name of the keystore as MSTeams.
- Enter a new password.
- Confirm the new password.
- In the confirmation dialog box, click OK.
- Click File > Save to save the keystore.
- Enter a new password.
- Confirm the new password.
- Select the location to save the keystore, and enter a keystore name.
- Right-click the newly keystore in the list of keystores, and then click Export > Export Certificate Chain.
- Keep the default value, and select a location to save the certificate.
- Click Export.
- In the confirmation dialog box, click OK.
- Close KeyStore Explorer.
- Open the exported certificate file by using a text editor.
- Copy the text in between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.
- Paste the text into a new text file.
- Remove the trailing space in each line to merge all the lines together to form one single line.
- Copy the single line of text as the certificate key.