Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 37e0091

Browse files
authored
[calendar] Add support for utterance like "my manager" or "his boss" (#2197)
* add support for utterance like "my manager" or "his boss" * fix GooglePeopleService * fix error with "Possessive" * fix the problems * fix problem * fix some problem * added nuget source to props file
1 parent 35f5cd4 commit 37e0091

25 files changed

+425
-7
lines changed

docs/_docs/reference/skills/productivity-calendar.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,31 @@ The following scenarios are currently supported by the Skill:
5454
- Time Remaining
5555
- *How long until my next meeting?*
5656
- *How many days are there until Thanksgiving?*
57+
58+
## Skill Deployment
59+
60+
The Calendar Skill require the following dependencies for end to end operation which are created through an ARM deployment script which you can modify as required.
61+
62+
- Azure Web App
63+
- Azure Storage Account (Transcripts)
64+
- Azure Application Insights (Telemetry)
65+
- Azure CosmosDb (State)
66+
- Azure Cognitive Services - Language Understanding
67+
68+
> Review the pricing and terms for the services and adjust to suit your scenario.
69+
70+
**To deploy your services using the default configuration, follow the steps in this common [deployment documentation page]({{site.baseurl}}/tutorials/csharp/create-assistant/4_provision_your_azure_resources/) from the folder where your have cloned the GitHub repo.**
71+
72+
### Authentication Connection Settings
73+
74+
If you plan to use the skill as part of a Virtual Assistant the process of registering a skill with your Virtual Assistant will create the supporting authentication connection information automatically for your Virtual Assistant. This skill uses the following authentication scopes which are registered automatically:
75+
76+
- `Calendars.ReadWrite`
77+
- `People.Read`
78+
- `Contacts.Read`
79+
- `User.Read.All`
80+
81+
**However**, if you wish to use the Skill directly without using a Virtual Assistant please use the following steps to manually configure Authentication for the Calendar Skill. This is **not** required when using the Skill with a Virtual Assistant.
5782

5883
## Language Understanding (LUIS)
5984

skills/src/csharp/Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
<ItemGroup>
1313
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />
1414
</ItemGroup>
15+
16+
<PropertyGroup>
17+
<RestoreAdditionalProjectSources>
18+
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
19+
</RestoreAdditionalProjectSources>
20+
</PropertyGroup>
1521

1622
<PropertyGroup>
1723
<Company>Microsoft</Company>

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/de/Calendar.lu

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,23 @@ $PREBUILT:ordinal
12491249

12501250
> # List entities
12511251

1252+
$PossessivePronoun:FirstPerson=
1253+
- mein
1254+
- unser
1255+
- meine eigene
1256+
- unsere eigenen
1257+
1258+
$PossessivePronoun:SecondPerson=
1259+
- Ihre
1260+
- Ihre eigenen
1261+
1262+
$PossessivePronoun:ThirdPerson=
1263+
- seine
1264+
- sie
1265+
- ihr
1266+
- seine eigenen
1267+
- ihre eigenen
1268+
12521269
$RelationshipName:tante=
12531270

12541271
$RelationshipName:tanten=

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/en/Calendar.lu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,24 @@ $PREBUILT:ordinal
14011401

14021402
> # List entities
14031403

1404+
$PossessivePronoun:FirstPerson=
1405+
- my
1406+
- our
1407+
- my own
1408+
- our own
1409+
1410+
$PossessivePronoun:SecondPerson=
1411+
- your
1412+
- your own
1413+
1414+
$PossessivePronoun:ThirdPerson=
1415+
- his
1416+
- her
1417+
- their
1418+
- his own
1419+
- her own
1420+
- their own
1421+
14041422
$RelationshipName:aunt=
14051423

14061424
$RelationshipName:aunts=

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/es/Calendar.lu

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,21 @@ $PREBUILT:ordinal
12151215

12161216
> # List entities
12171217

1218+
$PossessivePronoun:FirstPerson=
1219+
- Mi
1220+
- Nuestro
1221+
- mi propia
1222+
- nuestro propio
1223+
1224+
$PossessivePronoun:SecondPerson=
1225+
- usted
1226+
- su propia
1227+
1228+
$PossessivePronoun:ThirdPerson=
1229+
- suyos
1230+
- Su
1231+
- su propia
1232+
12181233
$RelationshipName:tía=
12191234

12201235
$RelationshipName:tías=

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/fr/Calendar.lu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,24 @@ $PREBUILT:ordinal
12321232

12331233
> # List entities
12341234

1235+
$PossessivePronoun:FirstPerson=
1236+
- mon
1237+
- notre
1238+
- mien
1239+
- notre propre
1240+
1241+
$PossessivePronoun:SecondPerson=
1242+
- ton
1243+
- votre propre
1244+
1245+
$PossessivePronoun:ThirdPerson=
1246+
- son
1247+
- son
1248+
- leur
1249+
- son propre
1250+
- son propre
1251+
- leur propre
1252+
12351253
$RelationshipName:tante=
12361254

12371255
$RelationshipName:tantes=

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/it/Calendar.lu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,24 @@ $PREBUILT:ordinal
12141214

12151215
> # List entities
12161216

1217+
$PossessivePronoun:FirstPerson=
1218+
- mio
1219+
- nostro
1220+
- il mio
1221+
- il nostro
1222+
1223+
$PossessivePronoun:SecondPerson=
1224+
- La tua
1225+
- il proprio
1226+
1227+
$PossessivePronoun:ThirdPerson=
1228+
- suo
1229+
- lei
1230+
- loro
1231+
- Propria
1232+
- proprio
1233+
- Proprio
1234+
12171235
$RelationshipName:zia=
12181236

12191237
$RelationshipName:zie=

skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/LU/zh/Calendar.lu

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,34 @@ $PREBUILT:ordinal
11441144

11451145
> # List entities
11461146

1147+
1148+
$PossessivePronoun:FirstPerson=
1149+
- 我
1150+
- 我们
1151+
- 我的
1152+
- 我们的
1153+
- 我自己的
1154+
- 我们自己的
1155+
1156+
$PossessivePronoun:SecondPerson=
1157+
- 你
1158+
- 你的
1159+
- 你自己的
1160+
1161+
$PossessivePronoun:ThirdPerson=
1162+
- 他
1163+
- 她
1164+
- 他们
1165+
- 她们
1166+
- 他的
1167+
- 她的
1168+
- 他们的
1169+
- 她们的
1170+
- 他自己的
1171+
- 她自己的
1172+
- 他们自己的
1173+
- 她们自己的
1174+
11471175
$DestinationCalendar:hotmail=
11481176

11491177
$DestinationCalendar:qq=

skills/src/csharp/calendarskill/calendarskill/Dialogs/CalendarSkillDialogBase.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,18 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
792792

793793
if (!isBeginDialog)
794794
{
795+
if (entity.RelationshipName != null)
796+
{
797+
state.MeetingInfor.CreateHasDetail = true;
798+
state.MeetingInfor.ContactInfor.RelatedEntityInfoDict = GetRelatedEntityFromRelationship(entity, luisResult.Text);
799+
if (state.MeetingInfor.ContactInfor.ContactsNameList == null)
800+
{
801+
state.MeetingInfor.ContactInfor.ContactsNameList = new List<string>();
802+
}
803+
804+
state.MeetingInfor.ContactInfor.ContactsNameList.AddRange(state.MeetingInfor.ContactInfor.RelatedEntityInfoDict.Keys);
805+
}
806+
795807
return;
796808
}
797809

@@ -813,6 +825,18 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
813825
state.MeetingInfor.ContactInfor.ContactsNameList = GetAttendeesFromEntity(entity, luisResult.Text, state.MeetingInfor.ContactInfor.ContactsNameList);
814826
}
815827

828+
if (entity.RelationshipName != null)
829+
{
830+
state.MeetingInfor.CreateHasDetail = true;
831+
state.MeetingInfor.ContactInfor.RelatedEntityInfoDict = GetRelatedEntityFromRelationship(entity, luisResult.Text);
832+
if (state.MeetingInfor.ContactInfor.ContactsNameList == null)
833+
{
834+
state.MeetingInfor.ContactInfor.ContactsNameList = new List<string>();
835+
}
836+
837+
state.MeetingInfor.ContactInfor.ContactsNameList.AddRange(state.MeetingInfor.ContactInfor.RelatedEntityInfoDict.Keys);
838+
}
839+
816840
if (entity.FromDate != null)
817841
{
818842
var dateString = GetDateTimeStringFromInstanceData(luisResult.Text, entity._instance.FromDate[0]);
@@ -944,6 +968,18 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
944968
}
945969
}
946970

971+
if (entity.RelationshipName != null)
972+
{
973+
state.MeetingInfor.CreateHasDetail = true;
974+
state.MeetingInfor.ContactInfor.RelatedEntityInfoDict = GetRelatedEntityFromRelationship(entity, luisResult.Text);
975+
if (state.MeetingInfor.ContactInfor.ContactsNameList == null)
976+
{
977+
state.MeetingInfor.ContactInfor.ContactsNameList = new List<string>();
978+
}
979+
980+
state.MeetingInfor.ContactInfor.ContactsNameList.AddRange(state.MeetingInfor.ContactInfor.RelatedEntityInfoDict.Keys);
981+
}
982+
947983
break;
948984
}
949985

@@ -1039,6 +1075,18 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
10391075
}
10401076
}
10411077

1078+
if (entity.RelationshipName != null)
1079+
{
1080+
state.MeetingInfor.CreateHasDetail = true;
1081+
state.MeetingInfor.ContactInfor.RelatedEntityInfoDict = GetRelatedEntityFromRelationship(entity, luisResult.Text);
1082+
if (state.MeetingInfor.ContactInfor.ContactsNameList == null)
1083+
{
1084+
state.MeetingInfor.ContactInfor.ContactsNameList = new List<string>();
1085+
}
1086+
1087+
state.MeetingInfor.ContactInfor.ContactsNameList.AddRange(state.MeetingInfor.ContactInfor.RelatedEntityInfoDict.Keys);
1088+
}
1089+
10421090
break;
10431091
}
10441092

@@ -1107,6 +1155,18 @@ protected async Task DigestCalendarLuisResult(DialogContext dc, CalendarLuis lui
11071155
}
11081156
}
11091157

1158+
if (entity.RelationshipName != null)
1159+
{
1160+
state.MeetingInfor.CreateHasDetail = true;
1161+
state.MeetingInfor.ContactInfor.RelatedEntityInfoDict = GetRelatedEntityFromRelationship(entity, luisResult.Text);
1162+
if (state.MeetingInfor.ContactInfor.ContactsNameList == null)
1163+
{
1164+
state.MeetingInfor.ContactInfor.ContactsNameList = new List<string>();
1165+
}
1166+
1167+
state.MeetingInfor.ContactInfor.ContactsNameList.AddRange(state.MeetingInfor.ContactInfor.RelatedEntityInfoDict.Keys);
1168+
}
1169+
11101170
state.ShowMeetingInfor.AskParameterContent = luisResult.Text;
11111171

11121172
break;
@@ -1381,6 +1441,22 @@ protected async Task<List<PersonModel>> GetUserAsync(WaterfallStepContext sc, st
13811441
return result;
13821442
}
13831443

1444+
protected async Task<PersonModel> GetMyManager(WaterfallStepContext sc)
1445+
{
1446+
var state = await Accessor.GetAsync(sc.Context);
1447+
var token = state.APIToken;
1448+
var service = ServiceManager.InitUserService(token, state.EventSource);
1449+
return await service.GetMyManagerAsync();
1450+
}
1451+
1452+
protected async Task<PersonModel> GetManager(WaterfallStepContext sc, string name)
1453+
{
1454+
var state = await Accessor.GetAsync(sc.Context);
1455+
var token = state.APIToken;
1456+
var service = ServiceManager.InitUserService(token, state.EventSource);
1457+
return await service.GetManagerAsync(name);
1458+
}
1459+
13841460
protected async Task<PersonModel> GetMe(ITurnContext context)
13851461
{
13861462
var state = await Accessor.GetAsync(context);
@@ -1436,6 +1512,39 @@ private List<string> GetAttendeesFromEntity(CalendarLuis._Entities entity, strin
14361512
return attendees;
14371513
}
14381514

1515+
private Dictionary<string, CalendarSkillState.RelatedEntityInfo> GetRelatedEntityFromRelationship(CalendarLuis._Entities entity, string inputString)
1516+
{
1517+
var entities = new Dictionary<string, CalendarSkillState.RelatedEntityInfo>();
1518+
1519+
int index = 0;
1520+
var rawRelationships = entity._instance.RelationshipName;
1521+
var rawPronouns = entity._instance.PossessivePronoun;
1522+
if (rawRelationships != null && rawPronouns != null)
1523+
{
1524+
foreach (var relationship in rawRelationships)
1525+
{
1526+
string relationshipName = relationship.Text;
1527+
for (int i = 0; i < entity.PossessivePronoun.Length; i++)
1528+
{
1529+
string pronounType = entity.PossessivePronoun[i][0];
1530+
string pronounName = rawPronouns[i].Text;
1531+
if (relationship.EndIndex > rawPronouns[i].StartIndex)
1532+
{
1533+
var originalName = inputString.Substring(rawPronouns[i].StartIndex, relationship.EndIndex - rawPronouns[i].StartIndex);
1534+
if (Regex.IsMatch(originalName, "^" + pronounName + "( )?" + relationshipName + "$", RegexOptions.IgnoreCase) && !entities.ContainsKey(originalName))
1535+
{
1536+
entities.Add(originalName, new CalendarSkillState.RelatedEntityInfo { PronounType = pronounType, RelationshipName = relationshipName });
1537+
}
1538+
}
1539+
}
1540+
1541+
index++;
1542+
}
1543+
}
1544+
1545+
return entities;
1546+
}
1547+
14391548
// Workaround until adaptive card renderer in teams is upgraded to v1.2
14401549
private string GetDivergedCardName(ITurnContext turnContext, string card)
14411550
{

0 commit comments

Comments
 (0)