Skip to main content

Hi,

In my app, I am adding an email address to a project. I am trying to trigger an event in Intercom that sends an invitation email.

First, I search for the email address, so I do not create multiple leads:

 

Connecting: api.intercom.io:443
Sending: POST http://api.intercom.io:443/contacts/search
Header: accept-encoding: gzip, deflate
Header: accept: application/vnd.intercom.3+json
Header: user-agent: Intercom-Ruby/4.2.1
Header: content-type: application/json
Header: acceptencoding: gzip, deflate
Header: authorization: Bearer REDACTED]
Header: host: api.intercom.io
Header: content-length: 159
Data: {"query":{"operator":"AND","value"::{"field":"email","operator":"=","value":""REDACTED]"},{"field":"role","operator":"=","value":"lead"}]}}
Status: 200
Benchmark: 0.493817 seconds
Header: date: Sat, 01 Jul 2023 04:45:04 GMT
Header: content-type: application/json; charset=utf-8
Header: transfer-encoding: chunked
Header: connection: keep-alive
Header: status: 200 OK
Header: x-ratelimit-limit: 167
Header: x-ratelimit-reset: 1688186711
Header: vary: Accept,Accept-Encoding
Header: x-ratelimit-remaining: 167
Header: x-intercom-version: 5404b96008c2cb8d59fba43f2a4614e0a1736517
Header: content-encoding: gzip
Header: x-request-id: 002i95tngf1earoa7rkg
Header: etag: W/"3accce3023253f75d3952041dc778ae0"
Header: x-frame-options: SAMEORIGIN
Header: cache-control: max-age=0, private, must-revalidate
Header: strict-transport-security: max-age=31556952; includeSubDomains; preload
Header: x-xss-protection: 1; mode=block
Header: intercom-version: 2.9
Header: x-runtime: 0.166042
Header: x-content-type-options: nosniff
Header: server: nginx
Header: x-ami-version: ami-05190846778a05936
Response:
{"type":"list","data"::],"total_count":0,"pages":{"type":"pages","page":1,"per_page":50,"total_pages":0}}

 

If I do not find it, I create the lead:

 

Connecting: api.intercom.io:443
Sending: POST http://api.intercom.io:443/contacts
Header: accept-encoding: gzip, deflate
Header: accept: application/vnd.intercom.3+json
Header: user-agent: Intercom-Ruby/4.2.1
Header: content-type: application/json
Header: acceptencoding: gzip, deflate
Header: authorization: Bearer eREDACTED]
Header: host: api.intercom.io
Header: content-length: 94
Data: {"email":""REDACTED]","role":"lead","name":""REDACTED]","custom_attributes":{}}
Status: 200
Benchmark: 0.491296 seconds
Header: date: Sat, 01 Jul 2023 04:45:05 GMT
Header: content-type: application/json; charset=utf-8
Header: transfer-encoding: chunked
Header: connection: keep-alive
Header: status: 200 OK
Header: x-ratelimit-limit: 167
Header: x-ratelimit-reset: 1688186711
Header: vary: Accept,Accept-Encoding
Header: x-ratelimit-remaining: 166
Header: x-intercom-version: 5404b96008c2cb8d59fba43f2a4614e0a1736517
Header: content-encoding: gzip
Header: x-request-id: 002ij2aiiguojsv4i2ug
Header: etag: W/"24b6a2f3065c70d377ed261ab1a65f60"
Header: x-frame-options: SAMEORIGIN
Header: cache-control: max-age=0, private, must-revalidate
Header: strict-transport-security: max-age=31556952; includeSubDomains; preload
Header: x-xss-protection: 1; mode=block
Header: intercom-version: 2.9
Header: x-runtime: 0.205667
Header: x-content-type-options: nosniff
Header: set-cookie: recent_write=343c3a66-2fbe-47e1-a1fc-ade9b8f359fd; path=/; max-age=1; HttpOnly; secure
Header: server: nginx
Header: x-ami-version: ami-05190846778a05936
Response:
{"type":"contact","id":""REDACTED]","workspace_id":""REDACTED]","external_id":""REDACTED]","role":"lead","email":""REDACTED]","phone":null,"name":""REDACTED]","avatar":null,"owner_id":null,"social_profiles":{"type":"list","data":a]},"has_hard_bounced":false,"marked_email_as_spam":false,"unsubscribed_from_emails":false,"created_at":1688186705,"updated_at":1688186705,"signed_up_at":null,"last_seen_at":null,"last_replied_at":null,"last_contacted_at":null,"last_email_opened_at":null,"last_email_clicked_at":null,"language_override":null,"browser":null,"browser_version":null,"browser_language":null,"os":null,"location":{"type":"location","country":null,"region":null,"city":null,"country_code":null,"continent_code":null},"android_app_name":null,"android_app_version":null,"android_device":null,"android_os_version":null,"android_sdk_version":null,"android_last_seen_at":null,"ios_app_name":null,"ios_app_version":null,"ios_device":null,"ios_os_version":null,"ios_sdk_version":null,"ios_last_seen_at":null,"custom_attributes":{},"tags":{"type":"list","data":a],"url":"/contacts/tREDACTED]/tags","total_count":0,"has_more":false},"notes":{"type":"list","data":a],"url":"/contacts/tREDACTED]/notes","total_count":0,"has_more":false},"companies":{"type":"list","data":a],"url":"/contacts/tREDACTED]/companies","total_count":0,"has_more":false},"opted_out_subscription_types":{"type":"list","data":a],"url":"/contacts/tREDACTED]/subscriptions","total_count":0,"has_more":false},"opted_in_subscription_types":{"type":"list","data":a],"url":"/contacts/tREDACTED]/subscriptions","total_count":0,"has_more":false},"utm_campaign":null,"utm_content":null,"utm_medium":null,"utm_source":null,"utm_term":null,"referrer":null,"sms_consent":false,"unsubscribed_from_sms":false}

 

I create an event for the lead, whether existing or newly created:

 

Connecting: api.intercom.io:443
Sending: POST http://api.intercom.io:443/events
Header: accept-encoding: gzip, deflate
Header: accept: application/vnd.intercom.3+json
Header: user-agent: Intercom-Ruby/4.2.1
Header: content-type: application/json
Header: acceptencoding: gzip, deflate
Header: authorization: Bearer aREDACTED]
Header: host: api.intercom.io
Header: content-length: 282
Data: {"event_name":"guest-invited","created_at":1688186705,"id":"iREDACTED]","metadata":{"invitation_link":"nREDACTED]","effi_event_name":"mREDACTED]"}}
Status: 202
Benchmark: 0.424042 seconds
Header: date: Sat, 01 Jul 2023 04:45:06 GMT
Header: content-type: text/html
Header: transfer-encoding: chunked
Header: connection: keep-alive
Header: status: 202 Accepted
Header: x-ratelimit-limit: 167
Header: x-ratelimit-reset: 1688186711
Header: x-intercom-version: 5404b96008c2cb8d59fba43f2a4614e0a1736517
Header: x-ratelimit-remaining: 165
Header: vary: Accept-Encoding
Header: content-encoding: gzip
Header: x-intercomrade: Like APIs? Check out https://www.intercom.io/careers
Header: x-request-id: 002jbokheh78hnc749lg
Header: x-frame-options: SAMEORIGIN
Header: cache-control: no-cache
Header: strict-transport-security: max-age=31556952; includeSubDomains; preload
Header: x-xss-protection: 1; mode=block
Header: intercom-version: 2.9
Header: x-runtime: 0.133361
Header: x-content-type-options: nosniff
Header: server: nginx
Response:

 

When the lead already exists, the event works and the email is sent. The problem: when a new lead is created (like the interaction above) - the event is not shown in Intercom and the email is not sent. The lead is created though, and if I try for the same lead again after a few minutes - the lead is found in search and the event is triggered.

So it seems there needs to be some time after a lead is created before an event can be triggered for that lead. The strange thing is, the event creation API seems to be successful, it responds with a 202.

Can somebody help in understanding what I am doing wrong?
 

Hi @EFFI Devops 👋 Eden from the support engineer team here.

 

It’s possible that a few seconds delay may be needed between the creation of the lead, then the triggering of the event for the lead. This might take a bit of additional investigation, so I have forwarded your issue to the Customer Support team on your behalf using the forum ticket escalation feature. The team will get back to you as soon as they can. Thank you! 


Reply