Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 774 Bytes

File metadata and controls

33 lines (27 loc) · 774 Bytes

go-tool-interface

Small Go SDK for registering external Open Chat tools.

Usage

package mytool

import "github.com/msgmate-io/go-tool-interface/toolinterface"

func init() {
	toolinterface.MustRegister(toolinterface.Definition{
		Name:        "my_tool",
		Description: "My external tool",
		InputType: struct {
			Message string `json:"message"`
		}{},
		RequiredParams: []string{"message"},
		Parameters: map[string]interface{}{
			"message": map[string]interface{}{"type": "string"},
		},
		Run: func(input interface{}, init map[string]interface{}) (string, error) {
			in := input.(struct {
				Message string `json:"message"`
			})
			return "echo: " + in.Message, nil
		},
	})
}

At build time, add your package import path in backend/tooldeps.json.