Hi Piyush,
You can do this in Apex by inserting a CollaborationInvitation.
String emailAddress = ‘bob2@external.com’;
CollaborationGroup chatterGroup = [SELECT Id
FROM CollaborationGroup
WHERE Name=’All acme.com’
LIMIT 1];
CollaborationInvitation inv = New CollaborationInvitation();
inv.SharedEntityId = chatterGroup.id;
inv.InvitedUserEmail = emailAddress;
try {
Insert inv;
} catch(DMLException e){
System.debug(‘There was an error with the invite: ‘+e);
}