Class DialogueResponsePowers

Hierarchy

  • DialogueResponsePowers

Index

Methods

Static isGetAdditionalTagDataEvent

  • isGetAdditionalTagDataEvent(): boolean
  • Returns whether the current event is the result of a user's request for additional data.

    example

    Run the skill if a user requests additional data.

     import { ISkillContext, ShouldIRunResponseType } from "andiskills";
     import { DialogueResponsePowers } from "@andi/powers";
    
     // shouldIRun is used by the andi skills platform to determine if the given
     // skill's current context needs to be executed.
     export async function shouldIRun(skillContext: ISkillContext): Promise<ShouldIRunResponseType> {
    
        // Run skill if user requests additional data
         if (DialogueResponsePowers.isGetAdditionalTagDataEvent()) {
             return skillContext.powers.andi.shouldIRun.shouldIRunTrue();
         }
    
         return skillContext.powers.andi.shouldIRun.shouldIRunFalse();
     }

    Returns boolean

    Returns whether the current event is the result of a user's request for additional data.

Static sendDialogueResponseWithTags

  • Sends a dialogue response with tags (optional) to the application.

    throws

    {Error} When dialogue options are missing or when included dialogue tags are null or are missing a name.

    throws

    {TypeError} When options is an invalid type.

    example

    In this example a DialogTag is returned with a helpful article in the Andi Dialog

    //Ensure you import DialogueResponsePowers
    //import {  DialogueResponsePowers, DialogueResponse} from "@andi/powers";
     const tag: DialogueTag = {
         name: "Test dialogue tag",
         tagType: FieldTagTypes.Info,
         text: "Here is a test help article.",
         onClick: [{
             name: "openNewTab",
             args: [articleUrl]
         }]
     };
    
     const dialogueResponse: DialogueResponse = {
         message: "I found this helpful article:",
         tags: [tag]
     };
    
     return DialogueResponsePowers.sendDialogueResponseWithTags(dialogueResponse);

    Parameters

    Returns Promise<ISkillActivity>

    Returns a dialogue response skill activity to the browser.

Static sendDialogueResponses

  • Sends multiple dialogue responses back to the application.

    example

    In this example returns two dialog response with helpful articles

    // Ensure you import DialogueResponsePowers
    // import {  DialogueResponsePowers, DialogueResponse} from "@andi/powers";
    
     const tag1: DialogueTag = {
         name: "Test dialogue tag",
         tagType: FieldTagTypes.Info,
         text: "Here is a test help article.",
         onClick: [{
             name: "openNewTab",
             args: [articleUrl]
         }]
     };
    
     const dialogueResponse1: DialogueResponse = {
         message: "I found this helpful article:",
         tags: [tag1]
     };
    
     const tag2: DialogueTag = {
         name: "Test dialogue tag",
         tagType: FieldTagTypes.Info,
         text: "Here is a test help article.",
         onClick: [{
             name: "openNewTab",
             args: [articleUrl]
         }]
     };
    
     const dialogueResponse2: DialogueResponse = {
         message: "I found this helpful article:",
         tags: [tag2]
     };
    
     return DialogueResponsePowers.sendDialogueResponses([dialogueResponse1,dialogueResponse2]);
    throws

    {Error} When options is not an array with at least one dialogue response.

    throws

    {Error} When any included dialogue tags are null or missing a name.

    Parameters

    • options: DialogueResponse[]

      DialogueResponse options for each dialogue response to be sent.

    Returns Promise<ISkillActivity>

    Returns a dialogue responses skill activity to the browser.

Generated using TypeDoc