Overview

This skill template allows you to start writing your skill code from scratch and is provided to you in your ASK Extension Kit. You can use this template to write one or a combination of the following skill types: email, field tag, or get help

This article assumes you have previously reviewed or have knowledge of the information contained in Navigating Your Andi® Skills Kit in the IDE and Getting Started.

 

'Skill' Template Code

Skill files will not contain any skill code with the exception of the code shown below. 

skillmanifest.json

{
    "description": "Andi New Skill",
    "skillConfigKeys": [],
    "locales": ["en-us"]
}

shouldIRun.ts 

import * as andiSkills from 'andiskills';
import * as andiExternal from 'andiexternal'

// shouldIRun is used by the andi skills platform to determine if the given
// skill's current context needs to be executed. 
export function shouldIRun(skillContext:andiSkills.ISkillContext): andiSkills.ShouldIRunResponse {

    // consult powers documentation for more details
    return skillContext.powers.andi.shouldIRun.shouldIRunFalse();

}

run.ts

import * as andiSkills from 'andiskills';
import * as andiExternal from 'andiexternal'

// this is main execution of the skill which is called after the andi
// skills platforms determines if it should run
// consult andi skills documentation for more details

export function run(skillContext: andiSkills.ISkillContext) : andiSkills.RunResponse{
    returnPromise.resolve(null);
}

 

'Skill' Template Code - Mocha Test

Mocha unit tests, while a good practice, are not required and will typically be utilized by skill writers with more programming experience.

In the 'Skill' template, test files will not contain any code other than an example of how a unit test can be defined to verify that the skill functions as expected. You will need to define your unit test code to verify your skill code.

shouldIRun.spec.ts

import * as assert from 'assert';
import { shouldIRun } from '../shouldIRun';
import * as andiSkills from 'andiskills';
import * as andiExternal from 'andiexternal'

describe("Skill ShouldIRun Tests", () => {

    // Defines a Mocha unit test
    it("Logs that it tried to run", (done) => {
        
        let skillContext: andiSkills.ISkillContext = andiExternal.MockSkillContextBuilder
            .forOpportunityChangeEvent()
            .build();
            
        andiExternal.ShouldIRunScenario
        .forGiven(skillContext)
        .execute(shouldIRun)
        .then((result) => {
            assert.notEqual(result,null);
            done();
        });

    });
    
}); 

run.spec.ts

import * as assert from 'assert';
import { run } from '../run';
import * as andiSkills from 'andiskills';
import * as andiExternal from 'andiexternal'

describe("Skill Run Tests", () => {

    // Defines a Mocha unit test
    it("Logs that it ran", (done) => {
        
        let skillContext: andiSkills.ISkillContext = andiExternal.MockSkillContextBuilder
            .forOpportunityChangeEvent()
            .build();
            
        andiExternal.RunScenario
        .forGiven(skillContext)
        .execute(run)
        .then((result) => {
            assert.equal(result,null);
            done();
        });
        
    });
    
});

 

Was this article helpful?
1 out of 1 found this helpful