User page view events to trigger custom bot welcome

An example flow of how we can leverage PageView events in Zendesk to give a better welcome prompt in Ultimate via uGPT.

I was inspired by the following quote from Hardcore Software by Steven Sinofsky:

Yes.. this is about Clippy.. 📎

Imagine the following:

A user browses a customers' website. They view pages and clearly have an intent.
When they open the web widget instead of a generic "Hey can I help you", or the widget opening with a proactive message based on the last URL, the customer gets a "It seems you're trying to accomplish X, here's some info".

That prompt is based on the pages viewed by the customer in their current session.

Example Flow. Customers would not see the middle one

What works now in Zendesk

A customer looks at Internal Note and checks out the following pages (reverse order)

He then goes to the web widget and talks to the to and an agent.

While browsing Zendesk collects his actions (URL, title) via an API call.
When he reaches the agent, that data shows up in the agent sidebar as Pages Viewed.

Storing actions

Sample 1

https://internalnote.zendesk.com/frontendevents/pv?client=1B752747-577B-429A-A0E0-83861AF69088

{
    "url": "https://internalnote.com/zendesk-acquires-ultimate/",
    "buid": "8d493a37ce5b44c6998fcf689097dcd0",
    "channel": "web_messenger",
    "version": "67c35ac",
    "timestamp": "2024-06-26T18:27:19.178Z",
    "suid": "4e3bc363544b46e19de46bd0bae61bf6",
    "pageView": {
        "pageTitle": "Zendesk acquires Ultimate: an in-depth overview of what the platform will gain",
        "referrer": "https://internalnote.com/road-to-automation/",
        "time": 2200,
        "loadTime": 2261,
        "navigatorLanguage": "en-US",
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
        "helpCenterDedup": false
    }
}
{
    "author": {
        "role": "appUser",
        "appUserId": "667c5d49e98c2bd1186f4f95",
        "client": {
            "platform": "web",
            "id": "8d493a37ce5b44c6998fcf689097dcd0",
            "integrationId": "61ea8723f4aa6100eb8a69e5",
            "info": {
                "vendor": "zendesk",
                "sdkVersion": "0.1",
                "URL": "internalnote.com",
                "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
                "referrer": "https://internalnote.com/ultimate-trends-2024/",
                "browserLanguage": "en-US",
                "currentUrl": "https://internalnote.com/road-to-automation/",
                "currentTitle": "Road to Automation"
            }
        }
    },
    "activity": {
        "type": "conversation:read"
    }
}

Sample 2

https://internalnote.zendesk.com/frontendevents/pv?client=1B752747-577B-429A-A0E0-83861AF69088

{
    "url": "https://internalnote.com/road-to-automation/",
    "buid": "8d493a37ce5b44c6998fcf689097dcd0",
    "channel": "web_messenger",
    "version": "67c35ac",
    "timestamp": "2024-06-26T18:28:28.704Z",
    "suid": "4e3bc363544b46e19de46bd0bae61bf6",
    "pageView": {
        "pageTitle": "Road to Automation",
        "referrer": "https://internalnote.com/zendesk-acquires-ultimate/",
        "time": 1584,
        "loadTime": 1634,
        "navigatorLanguage": "en-US",
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
        "helpCenterDedup": false
    }
}

Zendesk

Data Source

Zendesk pulls that data from:

https://d3v-verschoren.zendesk.com/api/lotus/graphql

{
    "data": {
        "user": {
            "id": "19776893760786",
            "events": {
                "edges": [
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:28:28.704Z",
                            "id": "01J1AWWVYVC9J64SHK6RWPAD1Q",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/zendesk-acquires-ultimate/\",\"session_id\":\"4e3bc363544b46e19de46bd0bae61bf6\",\"title\":\"Road to Automation\",\"url\":\"https://internalnote.com/road-to-automation/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:28:30.851041979Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    },
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:27:19.178Z",
                            "id": "01J1AWTR246DH3GSHS68TKAC9Q",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/road-to-automation/\",\"session_id\":\"4e3bc363544b46e19de46bd0bae61bf6\",\"title\":\"Zendesk acquires Ultimate: an in-depth overview of what the platform will gain\",\"url\":\"https://internalnote.com/zendesk-acquires-ultimate/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:27:21.323174035Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    },
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:26:05.139Z",
                            "id": "01J1AWRFW86WV62E9MCGT6CSHP",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/ultimate-trends-2024/\",\"session_id\":\"4e3bc363544b46e19de46bd0bae61bf6\",\"title\":\"Road to Automation\",\"url\":\"https://internalnote.com/road-to-automation/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:26:07.392282491Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    },
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:25:59.817Z",
                            "id": "01J1AWRAQ46CR3CCV4CRRKAD9K",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/zendesk-acquires-ultimate/\",\"session_id\":\"4e3bc363544b46e19de46bd0bae61bf6\",\"title\":\"Customer Service Trends 2024 - Zendesk Scorecard\",\"url\":\"https://internalnote.com/ultimate-trends-2024/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:26:02.119482773Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    },
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:25:14.44Z",
                            "id": "01J1AWPYBHC9GP4E1H6XJK2EB5",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/\",\"session_id\":\"4e3bc363544b46e19de46bd0bae61bf6\",\"title\":\"Zendesk acquires Ultimate: an in-depth overview of what the platform will gain\",\"url\":\"https://internalnote.com/zendesk-acquires-ultimate/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:25:16.676808358Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    },
                    {
                        "node": {
                            "createdAt": "2024-06-26T18:24:29.023Z",
                            "id": "01J1AWNJ1PCNK30EB571HK6S31",
                            "type": "page_view",
                            "source": "zendesk",
                            "properties": {
                                "data": "{\"channel\":\"web_messenger\",\"device_id\":\"8d493a37ce5b44c6998fcf689097dcd0\",\"referrer\":\"https://internalnote.com/\",\"session_id\":\"d30ebb1f36794df8a309778db04ffa3e\",\"title\":\"Internal Note\",\"url\":\"https://internalnote.com/\",\"user_agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\"}",
                                "__typename": "UserEventProps"
                            },
                            "receivedAt": "2024-06-26T18:24:31.294898508Z",
                            "__typename": "UserEvent"
                        },
                        "__typename": "UserEventEdge"
                    }
                ],
                "__typename": "UserEventConnection"
            },
            "__typename": "Customer"
        }
    },
    "extensions": {
        "depth": 6,
        "potentialNodeCount": 5
    }
}

GraphQL

query userPageViewQuery($userId: ID!, $first: Int!, $source: String!, $type: String!) {
  user(id: $userId) {
    id
    events(first: $first, source: $source, type: $type) {
      edges {
        node {
          createdAt
          id
          type
          source
          properties {
            data
            __typename
          }
          receivedAt
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
}
{
  "userId": 19776893760786,
  "type": "page_view",
  "source": "zendesk",
  "first": 20
}

Concept

What would happen if we pass that data to our Bot in the Welcome flow:

Proxy for the API

Since I don't control Ultimate ( 😅 ) I pulled the data from Zendesk and made it available as an API call. It returns the JQUERY data from Zendesk, but cleans up the big JSON file to a text string that works for Ultimate.

It runs at https://returnactivity.verschoren.workers.dev/19776893760786 and requires the ID of the current user. (Which is easily retrievable from the user metadata you get from SunCo.

SunCo Metadata

Managing user information
{
    "user": {
        "id": "deb920657bbc3adc3fec7963",
        "externalId": "user-id-231",
        "signedUpAt": "2015-10-08T23:52:11.677Z",
        "profile": {
            "givenName": "Steve",
            "surname": "Brule",
            "email": "steveb@channel5.com",
            "avatarUrl": "https://s3.amazonaws.com/avatar.jpg",
            "locale": "fr-CA"
        }
    }
}

Returned Data:

Road to Automation - https://internalnote.com/road-to-automation/ | Zendesk acquires Ultimate: an in-depth overview of what the platform will gain - https://internalnote.com/zendesk-acquires-ultimate/ | Road to Automation - https://internalnote.com/road-to-automation/ | Customer Service Trends 2024 - Zendesk Scorecard - https://internalnote.com/ultimate-trends-2024/ | Zendesk acquires Ultimate: an in-depth overview of what the platform will gain - https://internalnote.com/zendesk-acquires-ultimate/ | Internal Note - https://internalnote.com/

API Step

I then added an API step to my Welcome flow to get that data from the worker. Requires the aforementioned user_id

Welcome flow

💡
The DEMO flow has an extra step to choose if you want to use the events data, and it asks for the User ID if yes. This way I could test the concept without also building a flow to get the SunCo ID

The uGPT prompt:

Tell the customer about {{events}}. These are all indexed items in your knowledge base and data sources.

Sample Flow

Example 1

Darth Vader - ID 19776893760786

So based on the data available in Zendesk, when a customer loads the chat, they see this data

So a customer is exploring Ultimate on my blog >> they open the widget >> they see a summary of the article they are exploring.

Example 2

James Bond - ID 19777656776082

Conclusion

Please excuse the crudity of this model. I didn't have time to build it to scale or paint it. - Doc Brown

The above is obviously a rough proof of concept that lacks any finesse in the prompts used.

Improvements can be made by combining the websites found into a proper intent, and then using that to ask uGPT for an answer.

E.g. for my first example this would be a better input for uGPT

The user aims to explore automation strategies, understand Zendesk’s acquisition of Ultimate, and stay informed about customer service trends for 2024 via internalnote.com.

And this would return into:

Reference