Add a contact
File a person into the contact book by hand, and handle the case where they are already in it.
create_contact is the typed-in path into the contact book, the same one behind the dashboard's
own "add contact" form: a name and an email, with phone and company along for the ride. The book
is keyed by email, so sending one that already exists is not an error, it comes back as a normal
success naming the contact you already have.
Method
Create Contact
Adds a person to the contact book by hand, from typed details rather than from a received message. Takes only the fields a contact has, name, email, phone, company, job title and its kind (personal or business, which then needs no model to classify it), and ignores anything else the caller happens to hold, such as a shipping address. The email is the book's key, so it is required and a repeat of one already filed returns the existing contact instead of a second copy.
Walkthrough
Send the four fields a contact has
name and email are the only two create_contact requires. source defaults to manual and
context to Added by hand if you leave them out, both are shown on the contact's own activity
trail.
The response
existed: true is the duplicate path: the email was already in the book, and contact_id names
the contact that already had it rather than a new one. Branch on existed, not on code, to tell
the two cases apart, both come back as code: 1.
phone and company are stored on the contact but not echoed back in this response; read them
back with get_contacts or get_contact_members if you need to confirm what was saved.