# Salesforce

Attify reads Salesforce through its API, read-only, with OAuth or an API token, for customer support and sales meetings. It is the customer's own system, so what Attify reads there is connected data: the strongest provenance, and what a vendor verification rests on.

## As a help desk, for customer support

| Stored            | Salesforce                                                                  |
|-------------------|-----------------------------------------------------------------------------|
| id                | Case `Id`                                                                   |
| started_at        | Case `CreatedDate`                                                          |
| updated_at        | Case `SystemModstamp`, the sync cursor                                      |
| customer          | Case `ContactId`                                                            |
| channel           | Case `Origin`, lowercased                                                   |
| claim             | none yet: Agentforce's own session outcome (`AiAgentSessionEndType`,        |
|                   | resolved / escalated / deflected) lives in Data 360's session tracing, not  |
|                   | in the core API, so the claim is reconstructed                              |
| messages          | emails (`TextBody` at `MessageDate`; drafts left out) and published case    |
|                   | comments (`CommentBody`), oldest first. Internal comments are left out      |
| messages[].role   | an email's `Incoming`: the customer; a comment by a portal or guest user    |
|                   | (`User.UserType` other than Standard): the customer; anyone else: support   |
| messages[].author | an email whose `AutomationType` is AiAutomated (generated and sent by AI):  |
|                   | "ai"; AiAssisted (drafted by AI, sent by a person) or none: "human"         |
| reopens           | `CaseHistory` changes of `Status` from a closed status to an open one       |
|                   | (closed statuses from `CaseStatus.IsClosed`; field history must track       |
|                   | Status, and changes automation makes in system context are not recorded)    |
| merged_into       | a deleted case's `MasterRecordId` (a merged duplicate)                      |
| rating            | the latest completed Feedback Management survey response about the case:    |
|                   | its first numeric answer (`SurveyQuestionResponse.NumberValue`; the scale   |
|                   | is the survey's own, so it is stored but not read as satisfied or not).     |
|                   | Salesforce has no native CSAT; it never confirms a resolution               |

## As a crm or calendar, for sales meetings

| Stored            | Salesforce                                                                  |
|-------------------|-----------------------------------------------------------------------------|
| event id          | Event `Id` (child copies on invitees' calendars, `IsChild`, are skipped)    |
| started_at        | `CreatedDate`                                                               |
| updated_at        | `SystemModstamp`, the sync cursor                                           |
| start, end        | `StartDateTime` (else `ActivityDateTime`), `EndDateTime`                    |
| status            | cancelled when `IsDeleted` (queryAll), at its `SystemModstamp`; else booked |
| created_by, ai    | the `CreatedById` user: an Einstein Agent or Agentforce license or profile: |
|                   | an app, ai true; an API-only integration user (Salesforce Integration       |
|                   | license, an API Only profile) or the Automated Process user: an app, ai     |
|                   | null; a standard user with a readable profile: the user, ai false;          |
|                   | otherwise unknown                                                           |
| organizer         | the owner's email, when the owner is a user                                 |
| attendees         | EventRelation invitees (lead, contact and user emails; Status Accepted,     |
|                   | Declined, New as accepted, declined, none), and the `WhoId`'s email         |
| contacts          | `person:<WhoId>` and every lead or contact related to the event             |
| companies, deals  | `company:<AccountId>` (derived from the WhatId or the contact), and the     |
|                   | WhatId when it is an account; `deal:<WhatId>` when it is an opportunity     |
| title             | `Subject`                                                                   |
| person (Lead)     | `Email`; company: the converted account; lifecycle: `Status`; origin from   |
|                   | `LeadSource`; merged: the converted contact (`ConvertedContactId`)          |
| person (Contact)  | `Email`; company: `AccountId`; origin from `LeadSource`                     |
| company (Account) | the host of `Website`; customer_since: the earliest `CloseDate` of its won  |
|                   | opportunities, as of the account's last change (the won deal is a deal item |
|                   | of its own either way)                                                      |
| deal (Opportunity)| `AccountId`; people: its contact roles; closed_at: `CloseDate` once         |
|                   | `IsClosed`; won: `IsWon`; created_by as an event's                          |
