Hierarchy

  • EventPowers

Index

Methods

Methods

Static isCallbackEvent

  • isCallbackEvent(): boolean
  • Returns whether the current event was triggered by the sendSkillCallback context command.

    example

    In this example, the skill returns a field tag that calls the sendSkillCallback context command. When the callback is invoked, the skill uses isCallbackEvent to run a separate execution path.

    import { EventPowers, DialogueResponsePowers, TagPowers, DialogueTag, FieldTag } from "@andi/powers";
    import { FieldTagTypes, ISkillContext, ISkillActivity } from "andiskills";
    
    export async function run(skillContext: ISkillContext): Promise<ISkillActivity> {
        // If the skill was invoked by the `sendSkillCallback` context command, execute this code block
        if (EventPowers.isCallbackEvent()) {
            const dialogueTag: DialogueTag = {
                name: "dialogueTag",
                tagType: FieldTagTypes.Info,
                text: "Information"
            };
    
            return DialogueResponsePowers.sendDialogueResponseWithTags({
                message: "Here is more information",
                tags: [dialogueTag]
            });
        }
    
        const fieldTag: FieldTag = {
            fields: ["amount"],
            text: "Click here to see more information",
            tagType: FieldTagTypes.Info,
            key: "uniqueTemplateKey",
            onClick: [{
                name: "sendSkillCallback",
                args: [skillContext.skillMetadata.id]
            }]
        };
    
        return TagPowers.sendTags([fieldTag]);
    }

    Returns boolean

Generated using TypeDoc