diff --git a/services/connectors/telegram.go b/services/connectors/telegram.go index e0b3076..4e03fe1 100644 --- a/services/connectors/telegram.go +++ b/services/connectors/telegram.go @@ -146,11 +146,9 @@ func (t *Telegram) handleGroupMessage(ctx context.Context, b *bot.Bot, a *agent. // Cancel any active job for this chat before starting a new one t.cancelActiveJobForChat(update.Message.Chat.ID) - currentConv := a.SharedState().ConversationTracker.GetConversation(fmt.Sprintf("telegram:%d", update.Message.Chat.ID)) - // Clean up the message by removing bot mentions message := strings.ReplaceAll(update.Message.Text, "@"+botInfo.Username, "") - message = strings.TrimSpace(message) + update.Message.Text = strings.TrimSpace(message) // Send initial placeholder message msg, err := b.SendMessage(ctx, &bot.SendMessageParams{ @@ -188,6 +186,8 @@ func (t *Telegram) handleGroupMessage(ctx context.Context, b *bot.Bot, a *agent. chatMessage, ) + currentConv := a.SharedState().ConversationTracker.GetConversation(fmt.Sprintf("telegram:%d", update.Message.Chat.ID)) + // Create a new job with the conversation history and metadata job := types.NewJob( types.WithConversationHistory(currentConv),