Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 131 additions & 128 deletions OnGeneratedResponse/swap-citations.yml
Original file line number Diff line number Diff line change
@@ -1,128 +1,131 @@
kind: AdaptiveDialog
beginDialog:
kind: OnGeneratedResponse
id: main
condition: =CountRows(System.Response.Citations)>0
actions:
- kind: SetVariable
id: setVariable_xHJ4lf
variable: Topic.Var1
value: =System.Response.FormattedText

- kind: SetVariable
id: setVariable_wtNwaw
variable: Topic.externalWebsiteURL
value: https://yourwebsite.com/citations/

- kind: SetVariable
id: setVariable_9IFwdP
variable: Topic.CitationsSnip
value: |-
=With(
{CitationsTable: System.Response.Citations},
Concat(
ForAll(
Sequence(CountRows(CitationsTable)),
Value
),
With(
{
currentRecord: Index(
CitationsTable,
Value
)
},
//begin logic
"[" & Text(Value) & "]: " & If(
IsBlank(currentRecord.Url),
If(
Left(
currentRecord.Name,
8
) = "https://",
Substitute(
currentRecord.Name,
" ",
"%20"
),
Substitute((Topic.externalWebsiteURL & currentRecord.Name), " ", "%20") &
If(
// check if cited source is a PDF and we have page data available
And(
EndsWith(currentRecord.Name, ".pdf"),
StartsWith(currentRecord.Text, "<page value=")
),
// add page for PDFs
"#page=" & Mid(
currentRecord.Text,
Find("<page value=", currentRecord.Text
) + Len("<page value=") + 1,
Find(
">",
currentRecord.Text
) - Len("<page value=")-3
)
)
),
currentRecord.Url
) & " " & """" &
Substitute(
If(
Find(
"?",
Last(
Split(
currentRecord.Name,
"/"
)
).Value
) > 0,
Left(
Last(
Split(
currentRecord.Name,
"/"
)
).Value,
Find(
"?",
Last(
Split(
currentRecord.Name,
"/"
)
).Value
)
),
Last(
Split(
currentRecord.Name,
"/"
)
).Value
),
"%20",
" "
) & """"
//end logic
),
Char(10) & Char(10)
)
)

- kind: SendActivity
id: sendActivity_i4mW3G
activity: |-
{If(
System.Activity.ChannelId = "msteams",
System.Response.FormattedText & Char(10) & Char(10) & Text(Topic.CitationsSnip),
Left(System.Response.FormattedText, Find("[1]:", System.Response.FormattedText) + -1) & Char(10) & Char(10) & Text(Topic.CitationsSnip)
)}

- kind: SetVariable
id: setVariable_jVzQGX
variable: System.ContinueResponse
value: false

inputType: {}
outputType: {}
kind: AdaptiveDialog
beginDialog:
kind: OnGeneratedResponse
id: main
condition: =CountRows(System.Response.Citations)>0
actions:
- kind: SetVariable
id: setVariable_xHJ4lf
variable: Topic.Var1
value: =System.Response.FormattedText

- kind: SetVariable
id: setVariable_wtNwaw
variable: Topic.externalWebsiteURL
value:

- kind: SetVariable
id: setVariable_9IFwdP
variable: Topic.CitationsSnip
value: |-
=With(
{CitationsTable: System.Response.Citations},
Concat(
ForAll(
Sequence(CountRows(CitationsTable)),
Value
),
With(
{
currentRecord: Index(
CitationsTable,
Value
)
},
// Begin logic - Create Markdown link format for Teams
"[" & Text(Value) & "] [" &
Substitute(
If(
Find(
"?",
Last(
Split(
currentRecord.Name,
"/"
)
).Value
) > 0,
Left(
Last(
Split(
currentRecord.Name,
"/"
)
).Value,
Find(
"?",
Last(
Split(
currentRecord.Name,
"/"
)
).Value
) - 1
),
Last(
Split(
currentRecord.Name,
"/"
)
).Value
),
"%20",
" "
) & "](" &
If(
IsBlank(currentRecord.Url),
If(
Left(
currentRecord.Name,
8
) = "https://",
Substitute(
currentRecord.Name,
" ",
"%20"
),
Substitute((Topic.externalWebsiteURL & currentRecord.Name), " ", "%20") &
If(
// Check if cited source is a PDF or DOCX and we have page data available
And(
Or(
EndsWith(currentRecord.Name, ".pdf"),
EndsWith(currentRecord.Name, ".docx")
),
StartsWith(currentRecord.Text, "<page value=")
),
// Add page anchor for PDFs and DOCX files
"#page=" & Mid(
currentRecord.Text,
Find("<page value=", currentRecord.Text) + Len("<page value=") + 1,
Find(
">",
currentRecord.Text
) - Len("<page value=") - 3
),
""
)
),
currentRecord.Url
) & ")"
// End logic
),
Char(10) & Char(10)
)
)

- kind: SendActivity
id: sendActivity_i4mW3G
activity: |-
{If(
System.Activity.ChannelId = "msteams",
System.Response.FormattedText & Char(10) & Char(10) & Text(Topic.CitationsSnip),
Left(System.Response.FormattedText, Find("[1]:", System.Response.FormattedText) + -1) & Char(10) & Char(10) & Text(Topic.CitationsSnip)
)}

- kind: SetVariable
id: setVariable_jVzQGX
variable: System.ContinueResponse
value: false
inputType: {}
outputType: {}