Discord & Slack Benefits
Relevant source files
The following files were used as context for generating this wiki page:
Discord and Slack benefits are automated entitlements within the Polar platform that grant customers access to community workspaces and communication channels upon purchasing a product. These integrations allow creators to automate role assignment in Discord servers and the creation of shared channels in Slack, bridging the gap between payment processing and community engagement.
Sources: README.md:16-17, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:114-115
Discord Benefit Architecture
The Discord benefit is designed to automate server invites and role management. When a product containing this benefit is purchased, Polar interacts with the Discord API to assign a specific role to the subscriber.
Data Models and Schemas
The system uses Pydantic schemas to define the properties required for Discord integration, including server (guild) and role identification.
| Field | Type | Description |
|---|---|---|
guild_id | str | The unique identifier for the Discord server. |
role_id | str | The ID of the role to be granted to the subscriber. |
kick_member | bool | Determines if the user is removed from the server when the benefit is revoked. |
Sources: server/polar/benefit/strategies/discord/schemas.py:22-26, server/polar/benefit/strategies/discord/schemas.py:90-94
Guild Authentication
Security for Discord benefits is handled via guild_token, which is a JWT-encoded representation of the guild_id. This ensures that server identifiers are validated against Polar's internal secrets before benefit creation.
def guild_token(self) -> str:
return jwt.encode(
data={"guild_id": self.guild_id},
secret=settings.SECRET,
type="discord_guild_token",
)
Sources: server/polar/benefit/strategies/discord/schemas.py:28-34
Slack Shared Channel Architecture
The Slack benefit focuses on B2B or high-touch support by creating shared channels between the creator's workspace and the customer.
Logic and Configuration
The implementation involves complex frontend forms that manage Slack OAuth integrations and channel templates.
The diagram shows the logical flow of setting up a Slack Shared Channel benefit, from authentication to final configuration.
Sources: clients/apps/web/src/components/Benefit/SlackSharedChannelBenefitForm.tsx:112-250
Key Components
- Channel Name Template: Supports dynamic variables like
{customer_name}and{customer_email_local}. - Team Invitees: Allows selecting specific internal team members to be automatically added to every new customer channel.
- Revocation Logic: Includes an
archive_on_revokeflag, as Slack API does not support programmatic channel deletion.
Sources: clients/apps/web/src/components/Benefit/SlackSharedChannelBenefitForm.tsx:210-220, clients/apps/web/src/components/Benefit/SlackSharedChannelBenefitForm.tsx:280-285
AI-Assisted Configuration
Polar utilizes LLM-based agents to help users configure these benefits. However, due to the requirement for third-party OAuth authentication, the AI assistant has specific limitations regarding Discord and Slack setup.
Integration Workflow
While the AI can define the conceptual product, it routes users to manual setup for Discord and GitHub benefits because the user must interact with external OAuth flows that the chat interface cannot execute.
The sequence diagram illustrates how the AI assistant handles requests for benefits requiring third-party authentication.
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:133-140, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:390-395
Summary of Integration Properties
| Benefit Type | Primary Identifier | Key Automation | Revocation Behavior |
|---|---|---|---|
| Discord | guild_id | Role Assignment | Kick member (Optional) |
| Slack | slack_integration_id | Shared Channel Creation | Archive channel (Optional) |
Sources: server/polar/benefit/strategies/discord/schemas.py:22-26, clients/apps/web/src/components/Benefit/SlackSharedChannelBenefitForm.tsx:280-290
Discord and Slack benefits represent Polar's "Automated Benefits Engine," which extends standard payment processing into active user management within third-party ecosystems. By utilizing structured schemas and secure JWT-based tokens for guild identification, Polar ensures these entitlements are both scalable and secure for creators.
Sources: AGENTS.md:14-15, clients/apps/web/src/app/(main)/feedback/question/route.ts:50-55