Incoming email will come to an email address either of the form
service-user_identification_id-issue_id@whatever.com
or just service@whatever.com
.
service-user_identification_id-issue_id@whatever.com
Do a check to make sure that issue actually belongs to that user (check that issue_id and user_identification_id match in ec_customer_service_issues).
service@whatever.com
Just generate an interaction_id with ec_interaction_id_sequence. Then insert into ec_customer_serv_interactions (interaction_id, user_identification_id, interaction_date, interaction_originator, interaction_type, interaction_headers) values ($interaction_id, $user_identification_id, sysdate, 'customer', 'email', [the headers from the email]).
insert into ec_customer_service_actions (action_id, issue_id, interaction_id, action_details) values (ec_action_id_sequence.nextval, $issue_id, $interaction_id, [the body of the email])