diff --git a/OnGeneratedResponse/swap-citations.yml b/OnGeneratedResponse/swap-citations.yml index de468f1..e2fd0b6 100644 --- a/OnGeneratedResponse/swap-citations.yml +++ b/OnGeneratedResponse/swap-citations.yml @@ -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, "", - currentRecord.Text - ) - Len(" 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, "", + currentRecord.Text + ) - Len("