在自適性對話中使用宣告式資產Using declarative assets in adaptive dialogs

本文說明宣告式資產和 Bot 背後的概念,其中包含使用宣告式方法的自適性對話。This article explains the concepts behind declarative assets and bots that incorporate adaptive dialogs using the declarative approach. 宣告式自適性對話包含以 JSON 為基礎的檔案,這些檔案會描述自適性對話的所有屬性,包括其觸發程序動作Declarative adaptive dialogs consist of JSON-based files that describe all of the attributes of adaptive dialogs, including their triggers and actions. 這些宣告式檔案會在執行階段使用資源管理員來載入,以便建立自適性對話。These declarative files are loaded at run time using the resource manager to create the adaptive dialogs.

必要條件Prerequisites

宣告式檔案Declarative files

宣告式檔案目前包含 .dialog 檔案,這些檔案會描述自適性對話的所有屬性,以及包含 .lg 檔案,這些檔案是由定義 Bot 語言產生 (LG) 層面的 LG 範本所組成。Declarative files currently consist of .dialog files that describe all of the attributes of an adaptive dialog and .lg files that consist of LG templates that define the language generation (LG) aspects of your bot.

.dialog 檔案.dialog files

具有 .dialog 副檔名的自適性對話宣告式檔案包含下列元素:Adaptive dialog declarative files that have the .dialog extension contain the following elements:

  • $schema 值包含指向結構描述的 URI,該結構描述說明此宣告式檔案的格式。The $schema value contains a URI pointing to the Schema that describes the format of this declarative file. 該結構描述是 Bot Framework 元件結構描述,符合 JSON 結構描述詞彙的 Draft 7That schema is a Bot Framework component schema, which adheres to draft 7 of the JSON schema vocabulary. 此結構描述檔案可讓 IntelliSense 適用於您的宣告式元素。This schema file enables IntelliSense to work for your declarative elements. 如需有關如何建立此檔案的詳細資訊,請參閱_使用宣告式自適性對話建立 Bot_ 一文中的建立結構描述檔案For information on how to create this file, see Creating the schema file in the Create a bot using declarative adaptive dialogs article. 結構描述檔案的名稱可以是任何有效的檔案名稱,但是通常會命名為 app.schemaThe name of the schema file can be any valid filename, but is typically named app.schema.
  • [$kind] 欄位會識別此檔案中所描述的元件類型。The $kind field identifies the type of component described in this file. 針對自適性對話,$kind 必須是 Microsoft.AdaptiveDialogFor an adaptive dialog, $kind must be Microsoft.AdaptiveDialog. 在子物件中,$kind 會識別屬於對話的觸發程序或動作。In subobjects, $kind identifies a trigger or action that is part of the dialog. 此欄位與 [JsonProperty("$kind")] 類別屬性相互關聯,該屬性是與 Bot Framework SDK (設計目的是使用宣告式方法來運作) 中的每個類別相關聯。This field correlates with the [JsonProperty("$kind")] class attribute that is associated with every class in the Bot Framework SDK that is designed to work using the declarative approach.
  • recognizer 值包含辨識器類型以及一或多個意圖的陣列,並選擇性地包含一或多個實體的陣列。The recognizer value contains a recognizer type and an array of one or more intents and optionally an array of one or more entities.
  • generator 值包含 .lg 檔案的連結,該檔案與此 .dialog 檔案所定義的自適性對話相關聯。The generator value contains a link to the .lg file associated with the adaptive dialog that this .dialog file defines.
  • triggers 值包含一或多個觸發程序的陣列。The triggers value contains an array of one or more triggers. 觸發程序的類型是使用 $kind 關鍵字來宣告。The type of trigger is declared using the $kind keyword. 每個觸發程序都包含一或多個動作的陣列。Each trigger contains an array of one or more actions.
  • actions 值包含一或多個動作的陣列,每個動作都可以有與其相關聯的屬性。The actions value contains an array of one or more actions, each action can have properties associated with it.

簡單 .dialog 檔案的範例:An example of a simple .dialog file:

{
  "$schema": "../app.schema",
  "$kind": "Microsoft.AdaptiveDialog",
  "generator": "multiTurnPrompt.lg",
  "recognizer": {
      "$kind": "Microsoft.RegexRecognizer",
      "intents": [
          {
              "intent": "CancelIntent",
              "pattern": "(?i)cancel"
          }
      ]
  },
  "triggers": [
    {
      "$kind": "Microsoft.OnUnknownIntent",
      "actions": [
        {
          "$kind": "Microsoft.SendActivity",
          "activity":  "You said '${turn.activity.text}'"
        }
      ]
    }
  ]
}

注意

$schema 檔案可讓 IntelliSense 正常執行。The $schema file is what enables IntelliSense to work. 如果遺漏 $schema 關鍵字,或 $schema 值參考找不到的結構描述檔案,則不會發生警告或錯誤,IntelliSense 以外的所有項目仍會如預期般運作。No warning or error will occur if $schema keyword is missing or the $schema value references a schema file that cannot be found and everything except IntelliSense will still work as expected.

所定義 .dialog 檔案的元素:The elements of the .dialog file defined:

建立取得氣象資訊對話Create Get Weather Dialog

.lg 檔案.lg files

.lg 檔案格式一文中會詳細說明具有 .lg 副檔名的自適性對話宣告式檔案。Adaptive dialog declarative files that have the .lg extension are described in detail in the .lg file format article.

資源總管The resource explorer

資源總管會為您提供將宣告式自適性對話檔案匯入至 Bot 所需的工具,可以像是直接在您的 Bot 原始程式碼中定義自適性對話一樣使用這些工具。The resource explorer provides the tools you need to import declarative adaptive dialog files into your bot and use them as if they were adaptive dialogs defined directly in your bot source code.

使用資源總管,您可以建立資源物件,其中包含在執行階段建立自適性對話所需宣告式檔案的所有相關資訊,使用資源總管的類型載入器 (匯入具有 .dialog 和 .lg 副檔名的檔案) 來完成建立。With the resource explorer, you can create resource objects that contain all of the relevant information about the declarative files required to create adaptive dialogs at run time, which is done using the resource explorer's type loader that imports files with the .dialog and .lg extensions.

資源物件The resource object

資源總管的_取得資源_方法會將宣告式檔案讀取至資源物件。The resource explorer's get resource method reads the declarative file into a resource object. 資源物件包含宣告式檔案的相關資訊,而且可以由任何需要參考該檔案的程序 (例如類型載入器) 使用。The resource object contains the information about the declarative file and can be used by any process that needs to reference it, such as the type loader.

var resource = this.resourceExplorer.GetResource("main.dialog");

類型載入器The type loader

一旦資源瀏覽器的 _get resource_ 方法將宣告式檔案讀入資源物件,就會 _load type_method 將資源轉換成 AdaptiveDialog 物件。Once the resource explorer's _get resource_ method reads the declarative file into a resource object, the _load type_method casts the resource to an AdaptiveDialog object. 建立對話管理員時,可以使用 AdaptiveDialog 物件,就像任何其他非宣告式自適性對話一樣。The AdaptiveDialog object can be used the same as any other non-declarative adaptive dialog is used when creating a dialog manager.

dialogManager = new DialogManager(resourceExplorer.LoadType<AdaptiveDialog>(resource));

檔案變更時自動重新載入對話Auto reload dialogs when file changes

當您的 Bot 執行時,每當宣告式檔案變更時,就會引發_變更_事件。Any time a declarative file changes when your bot is running, a changed event fires. 您可以擷取該事件並重新載入宣告式檔案,如此一來,當任何自適性對話需要更新時,您不需要更新程式碼並重新編譯原始程式碼或重新啟動 Bot。You can capture that event and reload your declarative files, that way when any adaptive dialog needs updated you do not need to update your code and recompile your source code or restart your bot. 這在實際執行環境中特別有用。This can be especially useful in a production environment.

// auto reload the root dialog when it changes
this.resourceExplorer.Changed += (e, resources) =>
{
    if (resources.Any(resource => resource.Id == "main.dialog"))
    {
        Task.Run(() => this.LoadRootDialogAsync());
    }
};

private void LoadRootDialogAsync()
{
    var resource = this.resourceExplorer.GetResource("main.dialog");
    dialogManager = new DialogManager(resourceExplorer.LoadType<AdaptiveDialog>(resource));
}

VersionChanged事件The VersionChanged event

當您的宣告式資產重載以容納對檔案所做的變更時 .dialog ,您可能需要重新評估任何目前交談的狀態,以將對話的邏輯變更納入考慮。When your declarative assets have been reloaded to accommodate the changes made to a .dialog file, you may need to reevaluate the state of any current conversations to account of any changes to the logic of your dialog. 您的邏輯變更可能就像清除對話堆疊並重新啟動一樣簡單。The changes to your logic may be as simple as to clear your conversation stack and restart. 更精密的邏輯可讓您進行一些動作,例如重新開機對話方塊以保留您所擁有的資料,讓您可以挑選新的屬性,以及之前不存在的路徑。More sophisticated logic would enable you to do things like restart a dialog keeping the data you have, allowing you to pick up new properties and or paths that didn't exist before.

DialogEvents.VersionChanged使用觸發程式來捕獲事件 OnDialogEventThe DialogEvents.VersionChanged event is captured using the OnDialogEvent trigger.

Triggers = new List<OnCondition>()
{
    new OnDialogEvent(DialogEvents.VersionChanged)
    {
        Actions = new List<Dialog>()
        {
            new SendActivity("The VersionChanged event fired.")
        }
    }
}

宣告式資產Declarative assets

Bot Framework SDK 有各種可用的宣告式資產,每個項目都將會列在下方。The Bot Framework SDK has various declarative assets available, each will be listed below. 這些資產可以在您的 .dialog 檔案中當作 $kind 值來使用。These assets can be used in your .dialog files as the $kind value.

觸發程序Triggers

此區段包含所有觸發程序,並依類型分組:This section contains all triggers, grouped by type:

基底觸發程序Base trigger

$kind$kind value 觸發程序名稱Trigger Name 此觸發程序的作用What this trigger does
Microsoft.OnCondition OnCondition OnCondition 觸發程序是衍生所有觸發程序的基底觸發程序。The OnCondition trigger is the base trigger that all triggers derive from. 在自適性對話中定義觸發程序時,會將其定義為 OnCondition 觸發程序的清單。When defining triggers in an adaptive dialog they are defined as a list of OnCondition triggers.

辨識器事件觸發程序Recognizer event triggers

$kind$kind value 觸發程序名稱Trigger name 描述Description
Microsoft.OnChooseIntent OnChooseIntent 當在 CrossTrainedRecognizerSet 中多個識別器的意圖之間偵測到語意模糊時,就會執行此觸發程序。This trigger is run when ambiguity has been detected between intents from multiple recognizers in a CrossTrainedRecognizerSet.
Microsoft.OnIntent OnIntent 辨識指定意圖時要執行的動作。Actions to perform when specified intent is recognized.
Microsoft.OnQnAMatch OnQnAMatch QnAMakerRecognizer 傳回 QnAMatch 意圖時,就會執行此觸發程序。This trigger is run when the QnAMakerRecognizer has returned a QnAMatch intent. 實體 @answer 將會有 QnAMaker 答案。The entity @answer will have the QnAMaker answer.
Microsoft.OnUnknownIntent OnUnknownIntent 當使用者輸入無法辨識,或在任何 OnIntent 觸發程序中都找不到相符項時所要執行的動作。Actions to perform when user input is unrecognized or no match is found in any of the OnIntent triggers.

對話事件觸發程序Dialog event triggers

$kind$kind value 觸發程序名稱Trigger name 描述Description
Microsoft.OnBeginDialog OnBeginDialog 此對話開始時要執行的動作。Actions to perform when this dialog begins. 僅用於子對話。For use with child dialogs only.
Microsoft.OnCancelDialog OnCancelDialog 此事件可讓您防止因為子對話執行 CancelAllDialogs 動作而取消目前的對話。This event allows you to prevent the current dialog from being cancelled due to a child dialog executing a CancelAllDialogs action.
Microsoft.OnEndOfActions OnEndOfActions 當所有動作與語意模糊事件都已經處理之後,就會發生此事件。This event occurs once all actions and ambiguity events have been processed.
Microsoft.OnError OnError 發生 Error 對話事件時要執行的動作。Action to perform when an Error dialog event occurs. 此事件類似於 OnCancelDialog,因為您會使目前的對話無法結束,在此情況下是因為子對話發生錯誤。This event is similar to OnCancelDialog in that you are preventing the current dialog from ending, in this case due to an error in a child dialog.
Microsoft.OnRepromptDialog OnRepromptDialog 發生 RepromptDialog 事件時要執行的動作。Actions to perform when RepromptDialog event occurs.

重要

請勿在根對話中使用 OnBeginDialog 觸發程序,因為這可能會造成問題。Do not use the OnBeginDialog trigger in your root dialog as it can potentially cause problems. 您可以改為使用在根對話執行時將引發的 OnUnknownIntent 觸發程序。You can instead use the OnUnknownIntent trigger which will fire when your root dialog runs.

提示

大部分的子對話都包含可回應 BeginDialog 事件的 OnBeginDialog 觸發程序。Most child dialogs include an OnBeginDialog trigger that responds to the BeginDialog event. 此觸發程序會在對話開始時自動引發,可讓 Bot 立即以歡迎訊息或使用者輸入的提示回應。This trigger automatically fires when the dialog begins, which can allow the bot to respond immediately with a welcome message or a prompt for user input.

使用宣告式的對話事件觸發程序範例Dialog event trigger example using declarative
{
    "$schema": "../app.schema",
    "$kind": "Microsoft.AdaptiveDialog",
    "triggers": [
        {
            "$kind": "Microsoft.OnBeginDialog",
            "actions": [
                {
                    "$kind": "Microsoft.SendActivity",
                    "activity": "Hello world!"
                }
            ]
        }
    ]
}

活動事件觸發程序Activity event triggers

活動觸發程序可讓您將動作與用戶端的任何傳入活動產生關聯,例如當新的使用者加入,且 Bot 開始新的交談時。Activity triggers enable you to associate actions to any incoming activity from the client such as when a new user joins and the bot begins a new conversation. 如需活動的其他詳細資訊,請參閱 Bot Framework 活動結構描述Additional information on activities can be found in Bot Framework Activity schema.

$kind$kind value 觸發程序名稱Trigger name 描述Description
Microsoft.OnConversationUpdateActivity OnConversationUpdateActivity 處理使用者與 Bot 開始新的交談時所引發的事件。Handle the events fired when a user begins a new conversation with the bot.
Microsoft.OnEndOfConversationActivity OnEndOfConversationActivity 在收到類型為 EndOfConversation 的活動時所要執行的動作。Actions to perform on receipt of an activity with type EndOfConversation.
Microsoft.OnEventActivity OnEventActivity 在收到類型為 Event 的活動時所要執行的動作。Actions to perform on receipt of an activity with type Event.
Microsoft.OnHandoffActivity OnHandoffActivity 在收到類型為 HandOff 的活動時所要執行的動作。Actions to perform on receipt of an activity with type HandOff.
Microsoft.OnInvokeActivity OnInvokeActivity 在收到類型為 Invoke 的活動時所要執行的動作。Actions to perform on receipt of an activity with type Invoke.
Microsoft.OnTypingActivity OnTypingActivity 在收到類型為 Typing 的活動時所要執行的動作。Actions to perform on receipt of an activity with type Typing.

訊息事件觸發程序Message event triggers

訊息事件觸發程序可讓您對任何訊息事件做出反應,例如訊息已更新 (MessageUpdate) 或已刪除 (MessageDeletion) 或某人對訊息做出反應 (MessageReaction) 時 (例如,一些常見的訊息反應包括「讚」、「愛心」、「大笑」、「驚訝」、「悲傷」與「生氣」反應)。Message event triggers allow you to react to any message event such as when a message is updated (MessageUpdate) or deleted (MessageDeletion) or when someone reacts (MessageReaction) to a message (for example, some of the common message reactions include a Like, Heart, Laugh, Surprised, Sad and Angry reactions).

訊息事件是一種活動事件,因此,所有訊息事件都有 ActivityReceived 的基底事件,並依 ActivityType 進一步精簡。Message events are a type of activity event and as such, all message events have a base event of ActivityReceived and are further refined by ActivityType. 所有訊息觸發程序都衍生自基底類別 OnActivityThe Base class that all message triggers derive from is OnActivity.

$kind$kind value 觸發程序名稱Trigger name 描述Description
Microsoft.OnMessageActivity OnMessageActivity 在收到類型為 MessageReceived 的活動時所要執行的動作。Actions to perform on receipt of an activity with type MessageReceived.
Microsoft.OnMessageDeleteActivity OnMessageDeleteActivity 在收到類型為 MessageDelete 的活動時所要執行的動作。Actions to perform on receipt of an activity with type MessageDelete.
Microsoft.OnMessageReactionActivity OnMessageReactionActivity 在收到類型為 MessageReaction 的活動時所要執行的動作。Actions to perform on receipt of an activity with type MessageReaction.
Microsoft.OnMessageUpdateActivity OnMessageUpdateActivity 在收到類型為 MessageUpdate 的活動時所要執行的動作。Actions to perform on receipt of an activity with type MessageUpdate.

自訂事件觸發程序Custom event triggers

您可以透過將 EmitEvent 動作新增至任何觸發程序來發出自己的事件,然後透過定義_自訂事件_觸發程序,在 Bot 中任何對話的任何觸發程序中處理該自訂事件。You can emit your own events by adding the EmitEvent action to any trigger, then you can handle that custom event in any trigger in any dialog in your bot by defining a custom event trigger. 自訂事件觸發程序是一種 OnDialogEvent 觸發程序,其中 event 屬性與發出事件 event name 屬性的值相同。A custom event trigger is a type of OnDialogEvent trigger, where its event property to the same value as the emit event's event name property.

提示

您可以透過將發出事件的 bubble event 屬性設定為 true,讓 Bot 中的其他對話處理您的自訂事件。You can allow other dialogs in your bot to handle your custom event by setting the emit event's bubble event property to true.

$kind$kind value 觸發程序名稱Trigger name 描述Description
Microsoft.OnDialogEventMicrosoft.OnDialogEvent OnDialogEventOnDialogEvent 偵測到自訂事件時要執行的動作。Actions to perform when a custom event is detected. 使用發出自訂事件動作引發自訂事件。Use Emit a custom event' action to raise a custom event.

動作Actions

此區段包含所有動作,並依類型分組:This section contains all actions, grouped by type:

傳送回應Send a response

$kind$kind value 動作名稱Action Name 此動作的作用What this action does
Microsoft.SendActivity SendActivitySendActivity 可讓您傳送任何類型的活動,例如回應使用者。Enables you send any type of activity such as responding to users.

要求使用者輸入Requesting user input

$kind$kind value 輸入類別Input class 描述Description 傳回值Returns
Microsoft.AttachmentInput AttachmentInputAttachmentInput 用來要求/讓使用者上傳檔案Used to request/enable a user to upload a file. 附件物件的集合。A collection of attachment objects.
Microsoft.ChoiceInput ChoiceInputChoiceInput 用來要求從一組選項中選擇。Used to asks for a choice from a set of options. 選取項目的值或索引。The value or index of the selection.
Microsoft.ConfirmInput ConfirmInputConfirmInput 用來向使用者要求確認Used to request a confirmation from the user. 布林值。A Boolean value.
Microsoft.DateTimeInput DateTimeInputDateTimeInput 用來向使用者要求日期和/或時間Used to ask your users for a date and or time. 日期時間物件的集合。A collection of date-time objects.
Microsoft.InputDialog InputDialogInputDialog 這是所有輸入類別衍生自的基底類別。This is the base class that all of the input classes derive from. 其會定義所有共用屬性。It defines all shared properties.
Microsoft.NumberInput NumberInputNumberInput 用來向使用者要求數字Used to ask your users for a number. 數值。A numeric value.
Microsoft.OAuthInput OAuthInputOAuthInput 用來讓使用者登入安全網站Used to enable your users to sign into a secure site. 權杖回應。A token response.
Microsoft.TextInput TextInputTextInput 用來向使用者要求單字或句子Used to ask your users for a word or sentence. 字串。A string.

建立條件Create a condition

要完成的活動Activity to accomplish $kind$kind value 動作名稱Action Name 此動作的作用What this action does
分支:if/elseBranch: if/else Microsoft.IfCondition IfConditionIfCondition 用來建立 If 與 If-Else 陳述式,其用來執行只在條件為 True 時才執行的程式碼。Used to create If and If-Else statements which are used to execute code only if a condition is true.
分支:切換 (多個選項)Branch: Switch (Multiple options) Microsoft.SwitchCondition SwitchConditionSwitchCondition 用來建立多重選擇功能表。Used to build a multiple-choice menu.
迴圈:針對每個項目Loop: for each item Microsoft.Foreach ForEachForEach 對陣列中儲存的一組值進行迴圈。Loop through a set of values stored in an array.
迴圈:針對每個頁面 (多個項目)Loop: for each page (multiple items) Microsoft.ForeachPage ForEachPageForEachPage 對陣列中儲存的大型值組進行迴圈。Loop through a large set of values stored in an array one page at a time.
結束迴圈Exit a loop Microsoft.BreakLoop BreakLoopBreakLoop 脫離迴圈。Break out of a loop.
繼續迴圈Continue a loop Microsoft.ContinueLoop ContinueLoopContinueLoop 繼續迴圈。Continue the loop.
移至不同動作Goto a different Action Microsoft.GotoAction GotoActionGotoAction 立即移至所指定動作,並繼續執行。Immediately goes to the specified action and continues execution. 取決於 actionIdDetermined by actionId.

對話管理Dialog management

$kind$kind value 動作名稱Action Name 此動作的作用What this action does
Microsoft.BeginDialog BeginDialogBeginDialog 開始執行另一個對話。Begins executing another dialog. 當該對話完成時,將會繼續執行目前的觸發程式。When that dialog finishes, the execution of the current trigger will resume.
Microsoft.CancelDialog CancelDialog 取消作用中的對話。Cancels the active dialog. 當您想要讓對話立即關閉 (即使這表示停止中間程序) 時,可使用此動作。Use when you want the dialog to close immediately, even if that means stopping mid-process.
Microsoft.CancelAllDialogs CancelAllDialogsCancelAllDialogs 取消所有作用中的對話,包括任何作用中的父對話。Cancels all active dialogs including any active parent dialogs. 如果您想要將所有對話從堆疊中取出,請使用此動作,您可以透過呼叫對話內容的取消所有對話方法,來清除對話堆疊。Use this if you want to pop all dialogs off the stack, you can clear the dialog stack by calling the dialog context's cancel all dialogs method. 發出 CancelAllDialogs 事件。Emits the CancelAllDialogs event.
Microsoft.EndDialog EndDialogEndDialog 結束作用中的對話。Ends the active dialog. 當您想要完成對話並在結束前傳回結果時會使用。Use when you want the dialog to complete and return results before ending. 發出 EndDialog 事件。Emits the EndDialog event.
Microsoft.EndTurn EndTurnEndTurn 結束目前交談回合,而不結束對話。Ends the current turn of conversation without ending the dialog.
Microsoft.RepeatDialog RepeatDialogRepeatDialog 用來重新開始父對話。Used to restart the parent dialog.
Microsoft.ReplaceDialog ReplaceDialogReplaceDialog 以新對話取代目前的對話Replaces the current dialog with a new dialog
Microsoft.UpdateActivity UpdateActivityUpdateActivity 這可讓您更新已傳送的活動。This enables you to update an activity that was sent.
Microsoft.DeleteActivity DeleteActivityDeleteActivity 可讓您刪除已傳送的活動。Enables you to delete an activity that was sent.
Microsoft.GetActivityMembers GetActivityMembersGetActivityMembers 可讓您取得活動成員清單,並將其儲存至記憶體中的屬性。Enables you to get a list of activity members and save it to a property in memory.
Microsoft.GetConversationMembers GetConversationMembersGetConversationMembers 可讓您取得交談成員清單,並將其儲存至記憶體中的屬性。Enables you to get a list of the conversation members and save it to a property in memory.
Microsoft.EditActions EditActionsEditActions 可讓您根據使用者輸入,即時編輯目前的動作順序。Enables you to edit the current action sequence on the fly based on user input. 在處理 中斷時特別有用。Especially useful when handling interruptions.

管理屬性Manage properties

$kind$kind value 動作名稱Action Name 此動作的作用What this action does
Microsoft.EditArray EditArrayEditArray 這可讓您在陣列上執行編輯作業。This enables you to perform edit operations on an array.
Microsoft.DeleteProperty DeletePropertyDeleteProperty 這可讓您將屬性從記憶體中移除。This enables you to remove a property from memory.
Microsoft.DeleteProperties DeletePropertiesDeleteProperties 這可讓您在單一動作中刪除一個以上的屬性。This enables you to delete more than one property in a single action.
Microsoft.SetProperty SetPropertySetProperty 這可讓您在記憶體中設定屬性的值。This enables you to set a property's value in memory.
Microsoft.SetProperties SetPropertiesSetProperties 這可讓您在單一動作中初始化一或多個屬性。This enables you to initialize one or more properties in a single action.

存取外部資源Access external resources

$kind$kind value 動作名稱Action Name 此動作的作用What this action does
Microsoft.BeginSkill BeginSkillBeginSkill 使用自適性技能對話來執行技能。Use the adaptive skill dialog to run a skill.
Microsoft.HttpRequest HttpRequestHttpRequest 可讓您對任何端點提出 HTTP 要求。Enables you to make HTTP requests to any endpoint.
Microsoft.EmitEvent EmitEventEmitEvent 可讓您引發 Bot 可以使用自訂觸發程序回應的自訂事件。Enables you to raise a custom event that your bot can respond to using a custom trigger.
Microsoft.SignOutUser SignOutUserSignOutUser 可讓您將目前已登入的使用者登出。Enables you to sign out the currently signed in user.

偵錯選項Debugging options

$kind$kind value 動作名稱Action Name 此動作的作用What this action does
Microsoft.LogAction LogActionLogAction 寫入主控台,並選擇性地將訊息當作追蹤活動傳送。Writes to the console and optionally sends the message as a trace activity.
Microsoft.TraceActivity TraceActivityTraceActivity 使用您指定的任何承載傳送追蹤活動。Sends a trace activity with whatever payload you specify.

辨識器Recognizers

Bot Framework SDK 提供一半以上的辨識器,您可以在中指定要使用的辨識器,例如:The Bot Framework SDK provides over a half dozen different recognizers, you specify which recognizer to use in the .dialog file, for example:

{
    "$schema": "../app.schema",
    "$kind": "Microsoft.AdaptiveDialog",
    "recognizer": {
        "$kind": "Microsoft.RegexRecognizer",
        "intents": [
            {
                "intent": "JokeIntent",
                "pattern": "(?i)joke"
            },
            {
                "intent": "FortuneTellerIntent",
                "pattern": "(?i)fortune|future"
            },
            {
                "intent": "CancelIntent",
                "pattern": "(?i)cancel"
            }
        ]
    },
    ...
}

自適性對話方塊支援下列辨識器:Adaptive dialogs support the following recognizers:

產生器Generators

產生器值包含 .lg 檔案的連結,該檔案與此 .dialog 檔案所定義的自適性對話相關聯。The generator value contains a link to the .lg file associated with the adaptive dialog that this .dialog file defines. 例如:For example:

{
    "$schema": "../app.schema",
    "$kind": "Microsoft.AdaptiveDialog",
    "generator": "MyBotGeneratorFile.lg",
    ...
}

其他資訊Additional information