|  |  |  | @ -11,13 +11,22 @@ if (!API_URL || !INSTANCE_NAME || !API_KEY) { | 
		
	
		
			
				|  |  |  |  |   throw new Error('Required environment variables are not defined.'); | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // Send a message
 | 
		
	
		
			
				|  |  |  |  | export async function sendMessage(phone: string, message: string) { | 
		
	
		
			
				|  |  |  |  | // Send a message with optional mentions
 | 
		
	
		
			
				|  |  |  |  | export async function sendMessage(phone: string, message: string, mentions: string[] = []) { | 
		
	
		
			
				|  |  |  |  |   try { | 
		
	
		
			
				|  |  |  |  |     await axios.post(`${API_URL}/message/sendText/${INSTANCE_NAME}`, { | 
		
	
		
			
				|  |  |  |  |     const payload: any = { | 
		
	
		
			
				|  |  |  |  |       number: phone, | 
		
	
		
			
				|  |  |  |  |       text: message, | 
		
	
		
			
				|  |  |  |  |     }, { | 
		
	
		
			
				|  |  |  |  |     }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // Add mentions if provided
 | 
		
	
		
			
				|  |  |  |  |     if (mentions.length > 0) { | 
		
	
		
			
				|  |  |  |  |       payload.contextInfo = { | 
		
	
		
			
				|  |  |  |  |         mentionedJid: mentions | 
		
	
		
			
				|  |  |  |  |       }; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     await axios.post(`${API_URL}/message/sendText/${INSTANCE_NAME}`, payload, { | 
		
	
		
			
				|  |  |  |  |       headers: { | 
		
	
		
			
				|  |  |  |  |         'Content-Type': 'application/json', | 
		
	
		
			
				|  |  |  |  |         apikey: API_KEY, | 
		
	
	
		
			
				
					|  |  |  | 
 |