To add the ticket number received from an external system to a task, there are 2 methods:
Please read further under inbound email configuration how to set the proper email tags for processing an external ticket id through email.
The system provides a method through its webservice that allows the setting of the external Id. You can use the method "ProcessInstanceTaskExternalAcknowledgement" for setting the external reference number. For more information, check this url in your local setup: