Skip to content

Commit 38d99e0

Browse files
authored
Added travel-plan-topic (#28)
Added travel-plan-topic
2 parents ec0cf76 + 5c83e51 commit 38d99e0

File tree

7 files changed

+237
-0
lines changed

7 files changed

+237
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Travel Plan (Topic)
2+
3+
This is a snippet that demonstrates how to use an AI prompt in a Copilot Studio Topic. It uses an Adaptive Card to gather inputs and an AI prompt to generate a travel plan for a trip.
4+
5+
![A view of the output of the topic](./assets/travel-plan-topic.png)
6+
7+
## Authors
8+
9+
Snippet|Author(s)
10+
--------|---------
11+
Travel Plan (Topic) | [Daniel Laskewitz](https://github.com/laskewitz) ([@laskewitz](https://www.twitter.com/laskewitz))
12+
13+
## Minimal path to awesome
14+
15+
1. Open a copilot in **Copilot Studio**
16+
1. Select **Topics**
17+
1. Select **+ Add a topic**
18+
1. Select **From blank**
19+
1. Change the name from **Untitled** to **Travel Plan**
20+
1. Select **More**
21+
1. Select **Open code editor**
22+
1. Paste the contents of the **[YAML-file](./source/travel-plan.yaml)** in the code editor
23+
1. Select **Close code editor**
24+
25+
Don't worry about the error you'll see in the message card, later on that will disappear.
26+
27+
1. Select the **+** after the adaptive card to add a node
28+
1. Select **Call an action** in the popout
29+
1. Select **Create a prompt** in the next area
30+
31+
![View of the create prompt action.](./assets/create-prompt.png)
32+
33+
This will open the AI Builder prompt builder
34+
35+
1. Enter **Travel Plan** as the name for the prompt at the top
36+
1. Enter the following prompt as the prompt:
37+
38+
`Pease give me [Number] options for activities in [Destination] for people who are there for the first time. Please return a numbered list with emojis in the name of the activity and give it a brief description.`
39+
40+
1. Under Prompt settings, select **Input**
41+
1. Select **+ Add input**
42+
1. Enter **Number** as the name
43+
1. Enter **3** as the sample data
44+
1. Select **+ Add input** again
45+
1. Enter **Destination** as the name
46+
1. Enter **Amsterdam, The Netherlands** as the sample data
47+
1. Select **[Number]** in the prompt and remove it from the prompt, leaving the cursor on that spot
48+
1. Select the **+ Insert** button
49+
1. Select **Number** in the popout - this will add the input to your prompt
50+
1. Select **[Destination]** in the prompt and remove it from the prompt, leaving the cursor on that spot
51+
1. Select the **+ Insert** button again
52+
1. Select **Destination** in the popout to add destination to the prompt as well
53+
54+
Now you have replaced the text with actual inputs, and this means you can now test the prompt
55+
56+
1. Select the **Test prompt** button under the prompt to test the prompt with the sample data
57+
58+
This will show an example output of the prompt response in the Prompt response section
59+
60+
1. Select the **Save custom prompt** button
61+
1. Back in Copilot Studio, you will not directly see the prompt. Make sure to search for **Travel Plan** and it will show for you
62+
1. Select **Travel Plan**
63+
64+
![Screenshot of how to insert the prompt node into the topic](./assets/insert-prompt.png)
65+
66+
1. Select **>** in the **Destination** input and select the **destination** variable (this is the output of the adaptive card)
67+
1. Select **>** in the **Number** input and select the **number** variable
68+
1. Select **>** in the **predictionOutput** output and select the **Create new** button to create a new variable
69+
70+
This will automatically create a variable called *Var1*.
71+
72+
1. Select **Var1**
73+
74+
This will open the *Variable properties* panel
75+
76+
1. Change the name from **Var1** to **promptOutput**
77+
1. Close the **Variable properties** panel
78+
79+
![A view of the steps to be taken in the next steps](./assets/replace-message.png)
80+
81+
1. Select **Prompt output** in the message node by clicking on it (1)
82+
1. Remove the text **Prompt output**
83+
1. Select the variable icon **{x}** (2)
84+
1. Select **promptOutput.text** (3) - this is the generated text by the prompt.
85+
1. **Save** the topic
86+
1. Test out the **topic** by using the **Test copilot** section and send `Can you help me with a travel plan?`
87+
1. Fill in the card by adding a **Location** and a number of **Activities**
88+
1. When you get a response with a bunch of activities in the location you entered, you're **done**!
89+
90+
![A view of the output of the topic](./assets/travel-plan-topic.png)
91+
92+
## Disclaimer
93+
94+
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
95+
96+
<img src="https://m365-visitor-stats.azurewebsites.net/powerplatform-snippets/copilot-studio/travel-plan-topic" aria-hidden="true" />
143 KB
Loading
135 KB
Loading
122 KB
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[
2+
{
3+
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/samples/v1.0/metadata-schema.json",
4+
"name": "pnp-powerplatform-snippets-travel-plan-topic",
5+
"version": "1.0.0.0",
6+
"source": "pnp",
7+
"creationDateTime": "2024-08-27T00:00:00.000Z",
8+
"updateDateTime": "2024-08-27T00:00:00.000Z",
9+
"title": "Travel Plan (Topic)",
10+
"shortDescription": "This is a snippet that demonstrates how to use an AI prompt in a Copilot Studio Topic.",
11+
"longDescription": [
12+
"This is a snippet that demonstrates how to use an AI prompt in a Copilot Studio Topic. It uses an Adaptive Card to gather inputs and an AI prompt to generate a travel plan for a trip."
13+
],
14+
"url": "https://github.com/pnp/powerplatform-snippets/tree/main/copilot-studio/travel-plan-topic/",
15+
"products": [
16+
"Power Platform",
17+
"Copilot Studio",
18+
"powerplatform-snippets",
19+
"copilot-studio-snippets"
20+
],
21+
"tags": [
22+
],
23+
"categories": [
24+
],
25+
"metadata": [
26+
{
27+
"key": "Product",
28+
"value": "Copilot Studio"
29+
},
30+
{
31+
"key": "Type",
32+
"value": "Topic"
33+
}
34+
],
35+
"thumbnails": [
36+
{
37+
"type": "image",
38+
"order": 100,
39+
"url": "https://raw.githubusercontent.com/pnp/powerplatform-snippets/main/templates/previewsnippets.png",
40+
"alt": "Preview PNG"
41+
}
42+
],
43+
"authors": [
44+
{
45+
"gitHubAccount": "laskewitz",
46+
"name": "Daniel Laskewitz",
47+
"pictureUrl": "https://github.com/laskewitz.png"
48+
}
49+
]
50+
}
51+
]
146 KB
Loading
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
kind: AdaptiveDialog
2+
beginDialog:
3+
kind: OnRecognizedIntent
4+
id: main
5+
intent:
6+
triggerQueries:
7+
- Travel plans
8+
- Travel plan
9+
- Trip plans
10+
- Trip plan
11+
- Can you help me with a travel plan?
12+
- Travel plan help
13+
14+
actions:
15+
- kind: AdaptiveCardPrompt
16+
id: tZ7hl4
17+
interruptionPolicy:
18+
allowInterruption: false
19+
20+
repeatCount: 0
21+
card: |-
22+
{
23+
"type": "AdaptiveCard",
24+
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
25+
"version": "1.5",
26+
"body": [
27+
{
28+
"type": "TextBlock",
29+
"size": "Medium",
30+
"weight": "Bolder",
31+
"text": "✈️ Travel plan"
32+
},
33+
{
34+
"type": "TextBlock",
35+
"text": "We need a little bit more info from you to get you some recommendations",
36+
"wrap": true
37+
},
38+
{
39+
"type": "Container",
40+
"items": [
41+
{
42+
"type": "Input.Text",
43+
"placeholder": "Enter your destination",
44+
"label": "Where are you going to?",
45+
"id": "destination",
46+
"isRequired": true,
47+
"separator": true,
48+
"errorMessage": "Please enter the destination of your travel."
49+
},
50+
{
51+
"type": "Input.Text",
52+
"placeholder": "Enter the amount of activities",
53+
"label": "How many activities are you looking for?",
54+
"id": "number",
55+
"isRequired": true,
56+
"separator": true,
57+
"errorMessage": "Please enter a number of activities."
58+
},
59+
{
60+
"type": "ActionSet",
61+
"actions": [
62+
{
63+
"type": "Action.Submit",
64+
"title": "Submit"
65+
}
66+
]
67+
}
68+
],
69+
"style": "emphasis"
70+
}
71+
]
72+
}
73+
output:
74+
binding:
75+
actionSubmitId: Topic.actionSubmitId
76+
destination: Topic.destination
77+
number: Topic.number
78+
79+
outputType:
80+
properties:
81+
actionSubmitId: String
82+
destination: String
83+
number: String
84+
85+
- kind: SendActivity
86+
id: sendActivity_4AC9u6
87+
activity: 'Prompt output'
88+
89+
- kind: EndDialog
90+
id: INpkyZ

0 commit comments

Comments
 (0)