Follow these few steps to create your own addon.

TypeScript version

I recommend typescript version. In TypeScript, your IDE will guide you through available object properties with autocomplete. See How to use Typescript.

  1. Create typescript file ./client_add_on/hello_world.ts
    import { * } as ClientV2 from "../ClientV2";
    
    export = <ClientV2.Addon>function (addonParams: ClientV2.AddonParams) {
    
    	addonParams.registerRequestHandler ("helloWorld", function (params: ClientV2.RequestHandlerParams, callback) {
    		params.payload.context.result = "hello world!";
    	});
    	
    	addonParams.afterSkipUserInputCheck.observe(function (params) {
    		// eventualy also do some stuff after skip user input check, or any other event
    	});
    
    }
    
  2. Add your addon to the ./config.json
    {
    	"addons": [
    		"hello_world"
    	]
    }
    

JavaScript version

  1. Create typescript file ./client_add_on/hello_world.js
    module.export = function (addonParams) {
    
    	addonParams.registerRequestHandler ("hello_world", function (params, callback) {
    		params.payload.context.result = "hello world!";
    	});
    	
    	addonParams.afterSkipUserInputCheck.observe(function (params) {
    		// eventualy also do some stuff after skip user input check, or any other event
    	});
    
    }
    
  2. Add your addon to the ./config.json
    {
    	"addons": [
    		"hello_world"
    	]
    }
    

Data Types

/** Parameter passed to addon at startup. Contains everything addon needs. */
interface AddonParams {
	config: ServerConfig,
	/** Proxy for REST runtime API */
	dialogApi: DialogV2API;
	/** Observer of this event will be executed while processing message form user after there are is no more skip_user_input = true. That means just before sending response to the browser. */
	afterSkipUserInputCheck: ObserverCollection<{payload:BrowserToServerPayload, skipUserinputCheck: (payload: BrowserToServerPayload) => void }>;
	/** Register request handler */
	registerRequestHandler: (requestName: string, handler: RequestHandler) => void;
}

For more details about data structures see Data types