feat(telegram): add action to send telegram message (#147)

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-05-11 19:17:20 +02:00
committed by GitHub
parent 864bf8b94c
commit 2b07dd79ec
2 changed files with 169 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ const (
ActionCounter = "counter"
ActionCallAgents = "call_agents"
ActionShellcommand = "shell-command"
ActionSendTelegramMessage = "send-telegram-message"
)
var AvailableActions = []string{
@@ -79,6 +80,7 @@ var AvailableActions = []string{
ActionCounter,
ActionCallAgents,
ActionShellcommand,
ActionSendTelegramMessage,
}
func Actions(actionsConfigs map[string]string) func(a *state.AgentConfig) func(ctx context.Context, pool *state.AgentPool) []types.Action {
@@ -177,6 +179,8 @@ func Action(name, agentName string, config map[string]string, pool *state.AgentP
a = actions.NewCallAgent(config, agentName, pool.InternalAPI())
case ActionShellcommand:
a = actions.NewShell(config)
case ActionSendTelegramMessage:
a = actions.NewSendTelegramMessageRunner(config)
default:
xlog.Error("Action not found", "name", name)
return nil, fmt.Errorf("Action not found")
@@ -341,5 +345,10 @@ func ActionsConfigMeta() []config.FieldGroup {
Label: "Call Agents",
Fields: actions.CallAgentConfigMeta(),
},
{
Name: "send-telegram-message",
Label: "Send Telegram Message",
Fields: actions.SendTelegramMessageConfigMeta(),
},
}
}