mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 06:56:44 +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
|
const { data: agent } = await supabase
|
||||||
.from("agent_instances")
|
.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)
|
.eq("railway_service_id", serviceId)
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
|
|
@ -123,6 +125,19 @@ Deno.serve(async (req) => {
|
||||||
|
|
||||||
console.log(`railway-webhook: agent ${agent.id} marcado como active (status=${upper})`);
|
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)
|
// Notifica admin somente se era um auto-provisionamento (status anterior=provisioning)
|
||||||
if (wasProvisioning) {
|
if (wasProvisioning) {
|
||||||
const fullName = await loadFullName();
|
const fullName = await loadFullName();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue