mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 06:16:42 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
679802acf8
commit
dfd32f47c9
1 changed files with 16 additions and 1 deletions
|
|
@ -81,7 +81,9 @@ Deno.serve(async (req) => {
|
|||
|
||||
const { data: agent } = await supabase
|
||||
.from("agent_instances")
|
||||
.select("id, status, user_id, telegram_bot_username, railway_service_id")
|
||||
.select(
|
||||
"id, status, user_id, telegram_bot_username, railway_service_id, telegram_user_chat_id, telegram_bot_token_vault_id, agent_name, welcome_message_sent_at",
|
||||
)
|
||||
.eq("railway_service_id", serviceId)
|
||||
.maybeSingle();
|
||||
|
||||
|
|
@ -123,6 +125,19 @@ Deno.serve(async (req) => {
|
|||
|
||||
console.log(`railway-webhook: agent ${agent.id} marcado como active (status=${upper})`);
|
||||
|
||||
// Envia mensagem de boas-vindas via Telegram (apenas na primeira ativação)
|
||||
if (
|
||||
!agent.welcome_message_sent_at &&
|
||||
agent.telegram_user_chat_id &&
|
||||
agent.telegram_bot_token_vault_id
|
||||
) {
|
||||
try {
|
||||
await sendWelcomeMessage(supabase, agent);
|
||||
} catch (e) {
|
||||
console.error("railway-webhook: falha ao enviar welcome message:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Notifica admin somente se era um auto-provisionamento (status anterior=provisioning)
|
||||
if (wasProvisioning) {
|
||||
const fullName = await loadFullName();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue