Yes.
You should read the Twilio documentation first and foremost.
Probably this article that explains 99% of what you're trying to do: twilio.com/blog/2016/08/receive-sms-php-twilio.ht…
You'll see that an incoming SMS hits a PHP script to process, once you're in that script you can do whatever you want/need.