Declarative Agent for M365 Copilot by info.odysseyx@gmail.com October 29, 2024 written by info.odysseyx@gmail.com October 29, 2024 0 comment 9 views 9 This project demonstrates the use of declarative agents for Microsoft 365 Copilot, designed to create personalized experiences with specific instructions, tasks, and knowledge. This declarative agent specializing in ServiceNow leverages the following features and operations: SharePoint integration: Allows users to search for information in files, which provides context for ServiceNow tickets and can be useful for creating new tickets. graph connector: Leverage ServiceNow’s knowledge base and service catalog connectors to enhance functionality. plugin: Integrates the ServiceNow Script REST API, which allows users to list their incidents and create new incidents. memo: This sample code is for illustration purposes only and should not be deployed in a production environment without thorough review. Shows how to build a simple Declarative Copilot using Visual Studio Code and the Teams Toolkit. Please note that I do not receive any rights or permission from these organizations. Service Now and adventure time (Ice King logo). Prompt Sample 1. ServiceNow Knowledge Graph Connector: List articles about Outlook 2010. Place your results in a table with the article title in one column and a brief summary in another column. ServiceNow Service Catalog Graph Connector How do I request a new laptop? SharePoint features snow Lists the items in a spreadsheet and formats them as a table. Also add an integer column listing the item number as the first column. Plugin: List my events list my cases Plugin: Create new incident The following prompt uses the incident list returned from the previously run Snow spreadsheet file. I ask Copilot to create a new incident based on the sixth item in that list. Create a new incident for item 6. Building a basic declarative agent using the API plugin Declarative agents are a custom version of Microsoft 365 Copilot that help you create personalized experiences by declaring specific instructions, tasks, and knowledge. Declarative agents allow you to build custom versions of Copilot that can be used for specific scenarios, such as expertise, implementing a specific process, or simply saving time by reusing a set of AI prompts. For example, you can use the Grocery Shopping Copilot Declaration Agent to generate a grocery list based on a meal plan that you send to Copilot. You can use plugins to extend declarative agents to retrieve data and execute actions from external systems. Declarative agents can utilize multiple plugins simultaneously. Getting started Prerequisites To run this app template on your local development computer, you’ll need the following: First, select the Teams Toolkit icon on the left side of the VS Code toolbar. In the Account section, log in with the following account: Microsoft 365 account If you haven’t already. Click to create a Teams app Provision In the “Life Cycle” section. choose Preview in Copilot (Edge) or Preview in Copilot (Chrome) In the Launch Configuration dropdown Select a declarative agent from: Copilot app. Send a prompt. What’s included in the project folder contents .vscode VSCode file for debugging appPackage Templates for Teams application manifests, plugin manifests, and API specifications env environment file The following files are customizable and show example implementations to help you get started. file contents appPackage/declarativeCopilot.json Defines the behavior and configuration of a declarative agent. appPackage/manifest.json A Teams application manifest that defines metadata for the declarative agent. appPackage/instructions.txt Defines how agents communicate. Agents can be concise or detailed, interactive or implicit. It also includes any restrictions that must be applied. appPackage/ai-plugin.json It contains everything Copilot needs to know about your API that isn’t in the Swagger file. This breaks down the API into “functions” that share a common URL path and result set. appPackage/apiSpecificationFile/openapi.json Swagger file for API. The following are Teams Toolkit related project files. you can Visit the full guide on Github. Understand how the Teams Toolkit works. file contents teamsapp.yml This is the default Teams Toolkit project file. A project file defines two main things: properties and configuration step definitions. Additional Information and References ServiceNow plugin This project integrates with the ServiceNow platform using two ServiceNow Script REST APIs to enable seamless data exchange and automation of specific workflows. ServiceNow Script REST API ServiceNow’s scripted REST API allows developers to create custom web service APIs that can interact with ServiceNow data and services. These APIs can be configured to support a variety of HTTP methods (GET, POST, PUT, DELETE) and can be used to perform operations such as querying data, creating records, updating records, and deleting records. Create a scripted REST API This section contains code for a script REST API designed to list incidents related to a user. Go to System Web Services: movement System Web Services > Scripted Web Services > Scripted REST APIs. Create a new API: Click New Provide the name and namespace of your API. resource definition: Create a resource by specifying an HTTP method, relative path, and path parameters. Write a script: In the scripting window, write the scripts needed to process request and response objects. API testing: Use REST API Explorer to test your API and ensure it works as expected. List my events REST API The API is built on ServiceNow’s platform and leverages powerful scripting capabilities to retrieve and return incident data. This API supports the GET method and responds with a JSON object containing relevant incident details. (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { var username = request.pathParams.username; var instanceName = gs.getProperty('instance_name', 'default_instance'); username = username.replace(/\+/g, ' '); var gr = new GlideRecord('incident'); gr.addQuery('caller_id.name', username); gr.query(); var result = []; while (gr.next()) { result.push({ number: gr.getValue('number'), short_description: gr.getValue('short_description'), state: gr.getValue('state') }); } if (result.length === 0) { response.setStatus(404); response.setBody({error: 'No incidents found for the user name'}); } else { response.setStatus(200); response.setBody(result); } })(request, response); Create a new event This section contains code for a scripted REST API designed to create new incidents in ServiceNow. This API leverages the capabilities of ServiceNow to accept incident details through a POST request and create a record of that incident in the ServiceNow system. The request body must contain the required incident data, and if created successfully, the API will respond with details of the newly created incident. (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { var requestBody = request.body.data; if (!requestBody || !requestBody.short_description || !requestBody.username) { response.setStatus(400); response.setBody({error: "Missing required fields: short_description or username"}); return; } var userGr = new GlideRecord('sys_user'); userGr.addQuery('name', requestBody.username); userGr.query(); if (!userGr.next()) { response.setStatus(404); response.setBody({error: "User not found with username: " + requestBody.username}); return; } var callerId = userGr.sys_id; var gr = new GlideRecord('incident'); gr.initialize(); gr.short_description = requestBody.short_description; gr.description = requestBody.description; gr.caller_id = callerId; gr.category = requestBody.category || 'inquiry'; gr.impact = requestBody.impact || 3; gr.urgency = requestBody.urgency || 3; var incidentNumber; try { var sysId = gr.insert(); incidentNumber = gr.number; response.setStatus(201); response.setBody({ result: 'Incident created successfully', sys_id: sysId, number: incidentNumber }); } catch (e) { gs.error("Error creating incident: " + e.message); response.setStatus(500); response.setBody({error: "Error creating incident: " + e.message}); } })(request, response); There are two versions:The official API shared in the Microsoft repository connects to ServiceNow using a REST API developed by Cristiano.main copilot-pro-dev-samples/samples/da-SnowWizard · pnp/copilot-pro-dev-samples · GitHubMy version uses ServiceNow’s scripted REST API and uses two ServiceNow Graph connectors.GitHub – luishdemetrio/SnowKing This code is provided As is We make no warranties of any kind, either express or implied, including implied warranties of fitness for a particular purpose, merchantability or non-infringement. Source link Share 0 FacebookTwitterPinterestEmail info.odysseyx@gmail.com previous post SQL Konferenz: A Transformative Gathering of Data Experts next post Digital signage in Teams Rooms brings your messages to your meeting spaces You may also like Bots now dominate the web and this is a copy of a problem February 5, 2025 Bots now dominate the web and this is a copy of a problem February 5, 2025 Bots now dominate the web, and this is a problem February 4, 2025 DIPSEC and HI-STECS GLOBAL AI Race February 4, 2025 DEPSEC SUCCESS TICTOKE CAN RUNNING TO PUPPENSE TO RESTITE January 29, 2025 China’s AI Application DEPSEC Technology Spreads on the market January 28, 2025 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.