Skip to content

Commit 221a519

Browse files
authored
Merge branch 'master' into DOC-780
2 parents 27c0b7c + 7de5313 commit 221a519

File tree

6 files changed

+197
-1
lines changed

6 files changed

+197
-1
lines changed

src/_data/sidenav/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ sections:
390390
title: Audiences Overview
391391
- path: '/engage/audiences/account-audiences'
392392
title: Account-level Audiences
393+
- path: '/engage/audiences/generative-audiences'
394+
title: Generative Audiences
393395
- path: '/engage/audiences/organization'
394396
title: Organize Audiences
395397

src/connections/sources/catalog/libraries/server/node/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,46 @@ analytics.track({
653653
```
654654
655655
656+
## OAuth 2.0
657+
658+
> info ""
659+
> OAuth 2.0 is currently in private beta and is governed by Segment’s [First Access and Beta Preview Terms](https://www.twilio.com/en-us/legal/tos){:target="_blank"}.
660+
661+
Enable [OAuth 2.0](/docs/connections/oauth/) in your Segment workspace to guarantee authorized communication between your server environment and Segment's Tracking API. To support the non-interactive server environment, the OAuth workflow used is a signed client assertion JWT.
662+
663+
You will need a public and private key pair where:
664+
- The public key is uploaded to the Segment dashboard.
665+
- The private key is kept in your server environment to be used by this SDK.
666+
667+
Your server will verify its identity by signing a token request and will receive a token that is used to to authorize all communication with the Segment Tracking API.
668+
669+
You'll need to provide the OAuth Application ID and the public key's ID, both of which are provided in the Segment dashboard. There are also options available to specify the authorization server, custom scope, maximum number of retries, or a custom HTTP client if your environment has special rules for separate Segment endpoints.
670+
671+
Be sure to implement handling for Analytics SDK errors. Good logging helps distinguish any configuration issues.
672+
673+
For more information, see the [Segment OAuth 2.0 documentation](/docs/connections/oauth/).
674+
675+
```ts
676+
import { Analytics, OAuthSettings } from '@segment/analytics-node';
677+
import { readFileSync } from 'fs'
678+
679+
const privateKey = readFileSync('private.pem', 'utf8')
680+
681+
const settings: OAuthSettings = {
682+
clientId: '<CLIENT_ID_FROM_DASHBOARD>',
683+
clientKey: privateKey,
684+
keyId: '<PUB_KEY_ID_FROM_DASHBOARD>',
685+
}
686+
687+
const analytics = new Analytics({
688+
writeKey: '<MY_WRITE_KEY>',
689+
oauthSettings: settings,
690+
})
691+
692+
analytics.on('error', (err) => { console.error(err) })
693+
694+
analytics.track({ userId: 'foo', event: 'bar' })
695+
```
656696
## Troubleshooting
657697
658698
{% include content/troubleshooting-intro.md %}

src/connections/sources/catalog/libraries/server/python/index.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,49 @@ analytics.write_key = 'YOUR_WRITE_KEY'
530530

531531
## Google App Engine
532532

533-
Google App Engine my not resolve project dependencies. If this is the case add the following to your project alongside analytics-python:
533+
Google App Engine may not resolve project dependencies. If this is the case add the following to your project alongside analytics-python:
534534
- [requests](https://github.com/kennethreitz/requests){:target="_blank"}
535535
- python-dateutil](https://github.com/paxan/python-dateutil){:target="_blank"}
536536

537537
If you're having issues with threads outliving your request, check [Background threads and synchronous mode](#background-threads-and-synchronous-mode)
538538

539+
## OAuth 2.0
540+
541+
> info ""
542+
> OAuth 2.0 is currently in private beta and is governed by Segment’s [First Access and Beta Preview Terms](https://www.twilio.com/en-us/legal/tos){:target="_blank"}.
543+
544+
Enable [OAuth 2.0](/docs/connections/oauth/) in your Segment workspace to guarantee authorized communication between your server environment and Segment's Tracking API. To support the non-interactive server environment, the OAuth workflow used is a signed client assertion JWT.
545+
546+
You will need a public and private key pair where:
547+
- The public key is uploaded to the Segment dashboard.
548+
- The private key is kept in your server environment to be used by this SDK.
549+
Your server will verify its identity by signing a token request and will receive a token that is used to to authorize all communication with the Segment Tracking API.
550+
551+
You'll need to provide the OAuth Application ID and the public key's ID, both of which are provided in the Segment dashboard. There are also options available to specify the authorization server, custom scope, maximum number of retries, or a custom HTTP client if your environment has special rules for separate segment endpoints.
552+
553+
Be sure to implement handling for Analytics SDK errors. Good logging will help distinguish any configuration issues.
554+
555+
For more information, see the [Segment OAuth 2.0 documentation](/docs/connections/oauth/).
556+
557+
```python
558+
import segment.analytics as analytics
559+
with open("private_key.pem") as f:
560+
privatekey = f.read()
561+
562+
analytics.write_key = '<YOUR WRITE KEY HERE>'
563+
564+
analytics.oauth_client_id = 'CLIENT_ID' # OAuth application ID from segment dashboard
565+
analytics.oauth_client_key = privatekey # generated as a public/private key pair in PEM format from OpenSSL
566+
analytics.oauth_key_id = 'KEY_ID' # From segment dashboard after uploading public key
567+
568+
def on_error(error, items):
569+
print("An error occurred: ", error)
570+
analytics.on_error = on_error
571+
572+
analytics.track('AUser', 'track')
573+
analytics.flush()
574+
```
575+
539576
## Troubleshooting
540577

541578
### Request size limits
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Generative Audiences
3+
beta: true
4+
plan: engage-foundations
5+
---
6+
7+
> info "Generative Audiences is in private beta"
8+
> Generative Audiences is in private beta, and Segment is actively working on this feature. Some functionality may change before it becomes generally available. [Contact Segment](https://segment.com/help/contact/){:target="_blank"} with any feedback or questions.
9+
10+
With Generative Audiences, part of Segment's CustomerAI, use generative AI to create Engage Audiences with natural language prompts.
11+
12+
Describe your desired audience based on events performed, profile traits, or existing audiences in your workspace. Based on your prompt, Segment builds the audience with generative AI.
13+
14+
In this article, you'll learn how to use Generative Audiences along with some best practices.
15+
16+
## Create an audience with Generative Audiences
17+
18+
To create an audience with Generative Audiences:
19+
20+
1. From the Segment app, navigate to **Engage > Audiences**.
21+
2. Click **+ New audience**, then select **Audience** from the dropdown menu.
22+
3. Select your audience type. Generative Audiences is available for all audience types except Linked Audiences.
23+
4. From the Build screen, click **Build with AI**.
24+
5. Enter your audience prompt in the description box.
25+
- Use a minimum of 20 characters and up to 300 characters maximum.
26+
6. Click **Build**. Based on your prompt, CustomerAI generates audience conditions for your review.
27+
- Segment displays a progress bar until the audience conditions are generated.
28+
29+
> success ""
30+
> To help you write your prompt, view these [example prompts](#example-prompts) and [best practices](#best-practices).
31+
32+
### Modify an audience description
33+
34+
Once Segment generates the audience conditions, the prompt box remains open for reference. You can close this box, or modify your audience description and click **Build with AI** again.
35+
36+
Modifying an audience description overwrites the existing conditions previously generated. You can also edit any conditions straight from the audience builder.
37+
38+
## Example prompts
39+
40+
Use the following examples to help you get started with audience prompts.
41+
42+
- To build an audience with customers who haven't made a purchase in the last 30 days, enter: `Customers who haven't purchased in the last 30 days.`
43+
44+
- To find all profiles that have recently opened an email, enter: `Profiles that recently opened an email.`
45+
46+
- To build an audience with customers who spend over $50 on an order, enter: `Customers who have orders greater than $50.`
47+
48+
> info ""
49+
> You'll have more accurate results if you base your audience prompts on specific events and traits that are in your Segment space.
50+
51+
### Using negative conditions
52+
53+
Below are a few examples of how CustomerAI configures audience conditions for negative prompts. Negative conditions might include, for example, building an audience of users without a certain profile trait, or who haven't performed certain events.
54+
55+
1. **Prompt**: "Customers who have not purchased in the last 30 days."
56+
- **Expected output**: Segment generates audience conditions where *the event is performed at most 0 times*.
57+
58+
2. **Prompt**: "Customers who don't have a phone number."
59+
- **Expected output**: Segment generates audience conditions where *the trait doesn't exist*.
60+
61+
3. **Prompt**: "Customers who haven't received an email in the last 6 months."
62+
- **Expected output**: Segment generates audience conditions where *the event has been performed exactly 0 times*.
63+
64+
## Best practices
65+
66+
As you use Generative Audiences, keep the following best practices in mind:
67+
68+
- Avoid using any customer Personal Identifiable Information (PII) or sensitive data. Personal, confidential, or sensitive information isn't required to use CustomerAI.
69+
- Write specific descriptions. CustomerAI generates more accurate conditions when you use the names of existing events and traits.
70+
- Ensure that all events and traits you reference exist in your workspace.
71+
- Try different prompts. If you don't receive what you want on the first try, rewrite your prompt. Submitting a new prompt replaces existing conditions.
72+
- Preview your audience to ensure you're matching with the correct profiles prior to moving on to the next step.
73+
74+
### View events and traits in your workspace
75+
76+
As you're writing your prompt, you can view traits and events that are active in your workspace from the audience builder. After you add a condition in the builder, click the property field to view active and inactive traits or events in your workspace.
77+
78+
You can also use the Profile explorer (**Unify** > **Profile explorer**) to view specific events and traits associated with profiles in your Segment space.
79+
80+
Learn more about [using existing events and traits](/docs/engage/audiences/) to build audiences.
81+
82+
> warning ""
83+
> Due to a [limited space schema](#limited-space-schema), CustomerAI may not recognize some events or traits that are inactive in your workspace.
84+
85+
## Error handling
86+
87+
Engage uses the following error messages with Generative Audiences:
88+
89+
| Error message | Cause |
90+
|---------------------------|---------------------------------------|
91+
| Something went wrong | An unknown exception occurred. |
92+
| Something went wrong. Try again later. | The AI service is down, or the LLM returned an error. |
93+
| Segment had trouble creating an audience from this description. Try rewording it using these [best practices](#best-practices). | The prompt referenced an invalid or non-existing trait, audience, or event within the workspace. You may also see this when an audience description is impossible to build or misunderstood. |
94+
95+
## Known limitations
96+
97+
### Limited space schema
98+
99+
Segment's generative AI service is handled by a third party that needs context about your Engage workspace and has limitations to how many contextual parameters Segment can send it.
100+
Segment solves this limitation by including only the most recently used properties and values for events and traits within your Engage space. As a result, some event and traits within your workspace may not be recognized.
101+
102+
### Language support
103+
104+
At this time, Segment only supports audience description prompts in the English language. Support in other languages is currently unavailable and might provide undesired results.
105+
106+
107+
## More about Segment's generative AI service
108+
109+
#### How is my data used?
110+
111+
In order to generate the audience based on your description, Segment sends your query to OpenAI, Segment's 3rd party AI service. All queries sent to OpenAI from Segment are anonymized, meaning that OpenAI won't be able to identify from whom the query was sent unless you include uniquely identifiable information in the input.
112+
113+
Behind the scenes, Segment instructs GPT to generate an audience based on the user inputted audience description and contextual information such as traits and events performed in your workspace.
114+
115+
GPT is OpenAI's state-of-the-art natural language generation tool powered by artificial intelligence. It can perform a variety of natural language tasks like text generation, completion, and classification. CustomerAI uses the service to help generate audiences and inspire segmentation.
116+
117+
Per OpenAI's policy, data sent to OpenAI's API with Segment isn't used to train or improve their models and will be deleted after 30 days. Any content generated using GPT is your intellectual property. Segment won't assert any claims of copyright ownership on such content and makes no warranty of any kind with respect to any AI generated content.

src/engage/images/No-purchases.png

55.3 KB
Loading
57.8 KB
Loading

0 commit comments

Comments
 (0)