Read from imessage

I need help for my script: the script already sends an sms using imessage. To continue the applescript i wanna read the confirmation message in imessage
examplenumber: 12345678
message:confirm message

Processing a message you receive is a bit more tricky than sending one. You need to open preferences in the messenger app and set the applescript handler setting to a script that will process an incoming message.

The script you use should look something like this. You don’t need to worry about most of the code in there:

using terms from application "Messages"
	on message sent theMessage with eventDescription
		
	end message sent
	
	on message received theMessage from theBuddy for theChat with eventDescription
		#RIGHT HERE
                #eventDescription is the text of the incoming message. So you get it here and do whatever you want with it.
	end message received
	
	on chat room message received with eventDescription
		
	end chat room message received
	
	on active chat message received with eventDescription
		
	end active chat message received
	
	on addressed message received theMessage from theBuddy for theChat with eventDescription
		
	end addressed message received
	
	on received text invitation with eventDescription
		
	end received text invitation
	
	on received audio invitation theText from theBuddy for theChat with eventDescription
		
	end received audio invitation
	
	on received video invitation theText from theBuddy for theChat with eventDescription
		
	end received video invitation
	
	on «event ichthe15» given «class hepr»:theBuddy, «class hect»:theChat, «class heed»:eventDescription
		
	end «event ichthe15»
	
	on buddy authorization requested with eventDescription
		
	end buddy authorization requested
	
	on addressed chat room message received with eventDescription
		
	end addressed chat room message received
	
	on «event ichthe16» given «class heed»:eventDescription
		
	end «event ichthe16»
	
	# The following are unused but need to be defined to avoid an error
	
	on login finished with eventDescription
		
	end login finished
	
	on logout finished with eventDescription
		
	end logout finished
	
	on buddy became available with eventDescription
		
	end buddy became available
	
	on buddy became unavailable with eventDescription
		
	end buddy became unavailable
	
	on received file transfer invitation theFileTransfer with eventDescription
		
	end received file transfer invitation
	
	on av chat started with eventDescription
		
	end av chat started
	
	on av chat ended with eventDescription
		
	end av chat ended
	
	on completed file transfer with eventDescription
		
	end completed file transfer
	
end using terms from