Gmail Webhook Payload

Gmail webhooks are sent for incoming and outgoing emails.

Example payload

1{
2 "event": {
3 "id": "evt_gmail_abc123",
4 "channel": "gmail",
5 "timestamp": 1706640000.0,
6 "data": {
7 "timestamp": 1706640000.0,
8 "direction": "inbound",
9 "platform": "gmail",
10 "email_id": "email_xyz789",
11 "message_id": "<CADmL4p5xyz@mail.gmail.com>",
12 "subject": "Question about your services",
13 "body": "<html><body><p>Hi, I'm interested in learning more about...</p></body></html>",
14 "body_plain": "Hi, I'm interested in learning more about...",
15 "is_from_account": false,
16 "account_id": "acc_123",
17 "from_attendee": {
18 "display_name": "John Doe",
19 "identifier": "john@example.com",
20 "identifier_type": "EMAIL_ADDRESS"
21 },
22 "to_attendees": [
23 {
24 "display_name": "Your Business",
25 "identifier": "hello@yourbusiness.com",
26 "identifier_type": "EMAIL_ADDRESS"
27 }
28 ],
29 "cc_attendees": [],
30 "bcc_attendees": [],
31 "reply_to_attendees": [],
32 "email_event_type": "mail_received",
33 "date": 1706640000.0,
34 "read_date": null,
35 "folders": ["INBOX"],
36 "has_attachments": true,
37 "attachments": [
38 {
39 "id": "att_001",
40 "name": "proposal.pdf",
41 "size": 102400,
42 "mimetype": "application/pdf",
43 "url": "https://..."
44 }
45 ],
46 "in_reply_to": null,
47 "is_complete": true,
48 "tracking_id": "track_abc",
49 "origin": "external",
50 "usage_data": {
51 "prompt_tokens": 300,
52 "completion_tokens": 150,
53 "model": "gpt-4"
54 },
55 "tools_called": ["check_availability"],
56 "analysis_result": {
57 "sentiment": "positive",
58 "intent": "inquiry"
59 }
60 }
61 },
62 "lead_id": "lead_123",
63 "lead_contact": {
64 "number": "",
65 "email": "john@example.com",
66 "name": "John Doe"
67 },
68 "business_id": "biz_456",
69 "lead_created": true
70}

Field reference

Core fields

FieldTypeRequiredDescription
timestampfloatYesUnix epoch timestamp
directionstringYesinbound or outbound
platformstringYesAlways gmail
email_idstringYesInternal email ID
message_idstringYesRFC822 Message-ID header
subjectstringYesEmail subject line
bodystringYesHTML email body
is_from_accountbooleanYesTrue if sent by connected account
account_idstringYesConnected Gmail account ID
email_event_typestringYesEvent type
datefloatYesServer acknowledgment timestamp

email_event_type values

ValueDescription
mail_receivedIncoming email
mail_sentOutgoing email

from_attendee object

FieldTypeDescription
display_namestringSender display name (optional)
identifierstringEmail address
identifier_typestringAlways EMAIL_ADDRESS

to_attendees array

Array of recipient objects with same structure as from_attendee.

Optional fields

FieldTypeDescription
body_plainstringPlain text version of body
cc_attendeesarrayCC recipients
bcc_attendeesarrayBCC recipients
reply_to_attendeesarrayReply-To addresses
read_datefloatWhen email was read
foldersarrayEmail folders (INBOX, SENT, etc.)
rolestringFolder role
has_attachmentsbooleanWhether has attachments
attachmentsarrayEmail attachments
in_reply_toobjectParent email reference
is_completebooleanWhether fully loaded
tracking_idstringInternal tracking ID
originstringunipile or external
usage_dataobjectLLM token usage
tools_calledarrayTool names executed
analysis_resultobjectAI analysis output
appointmentsarrayExtracted appointments
execution_contextobjectSource trigger context

attachments array

FieldTypeDescription
idstringAttachment ID
namestringFilename
sizeintegerSize in bytes
mimetypestringMIME type
urlstringDownload URL

in_reply_to object

FieldTypeDescription
message_idstringParent RFC822 Message-ID
idstringParent internal ID

origin values

ValueDescription
externalEmail from external sender
unipileEmail sent via BookedIn