Okay
  Public Ticket #3813385
Conversations
Closed

Comments

  •  7
    Chris Chiarelli started the conversation

    I want to come up with a way, that our customer can message their assigned sales represtative.  I see you have "Conversations" and was trying to see if that can work for our needs.  Every customer has an assigned sales rep which we use a b2b king custom field for which we store under the user registartion data.  Any thoughts on it being possible where we can have a button for the customer on our page when logged in, and they can message their assigned sales rep? 

  •  2,330
    WebWizards replied

    Hello Chris,

    For sales reps, are you using our SalesKing plugin, or is it some other / custom solution?

    If it's a separate solution, is the idea that that button would send an email to the rep, or how would that work?

     

    Kind regards,

    Stefan

  •  7
    Chris Chiarelli replied

    We are not using salesking, but are open to it..  We are simply using a b2bking registration field to store the sales rep data and then having the data inserted into the post sale email that comes from the site to our staff. 

  •  7
    Chris Chiarelli replied

    I just looked at sales rep king and I dont think we would utilize those features.. 

  •  2,330
    WebWizards replied

    If it would help, I think we could provide a code snippet that does the following:

    -> Modify the recipient of the conversation "new message" email (that the admin normally gets), so that the email is sent to the user's rep instead.

    -> Add the customer's email address to the email so that the rep can see it and reply back to them.

  •  7
    Chris Chiarelli replied

    That would help.. I would just need a page or db to house a lookup list for rep name and email. 

  •  2,330
    WebWizards replied

    To achieve that, you can:

    (1) Add this PHP code snippet to change who receives the 'new message' email: 

    add_filter('b2bking_recipient_new_message', function($recipient, $conversationid){
    		$user_id = get_current_user_id();
    		// get sales rep
    		$sales_rep_email = get_user_meta($user_id, 'sales_rep_email', true);
    		if (!empty($sales_rep_email)){
    			$recipient = $sales_rep_email;
    		}
    
    		return $recipient;
    	}, 10, 2);

    The above snippet assumes that the customer has a user meta key 'sales_rep_email' that holds the email address of the rep, so for example 'sales_rep_email' would contain '[email protected]', and the email would be sent to that agent.

     

    (2) You can add this PHP code snippet to the site:

    add_action('b2bking_conversation_message_start', function(){
        if (isset($_POST['message'])){
            $user = wp_get_current_user();
            $user_email = $user->user_email;
            $_POST['message'].='<br>User: '.$user_email;
        }
    });

    This adds a "user: [email protected]" to the email automatically, so that the agent can view the customer's email based on the message.