-
Notifications
You must be signed in to change notification settings - Fork 10
Add docs for global trigger events, app mentions #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6a8eab
initial commit
slowcooked99 53298f1
clean-up
slowcooked99 6d58da3
Rename Global Triggers to App Mention Triggers
stacy-qqq ded0ae7
Rename global triggers to app mention triggers
stacy-qqq 75bae24
Add form for limited access.
stacy-qqq 07f5374
Added form to request access.
stacy-qqq 717f8a6
Merge branch 'main' into DX-11040-global-trigger-app-mention-docs
slowcooked99 3b04b26
remove ban check restriction
slowcooked99 d82050f
update other .mdx file too
slowcooked99 cf7d705
address feedback, pending access request link
slowcooked99 f17f6e8
restore Stacy's commits
slowcooked99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import Tabs from "@theme/Tabs"; | ||
| import TabItem from "@theme/TabItem"; | ||
|
|
||
| # App Mention Triggers | ||
|
|
||
| App mention triggers let your app respond to Reddit events even when those events happen outside the subreddit where your app is installed. App mention triggers are limited to app usernames. | ||
|
|
||
| Devvit currently supports one global trigger: `onMentionInCommentCreate` | ||
|
|
||
| :::note | ||
| This is a limited-access feature. Fill out this [form](https://docs.google.com/forms/d/e/1FAIpQLScLU2m-IH9xtt4hqFBNy5AlrswY0pvfvoyTiQREbq_9xDQJkQ/viewform) to request access. | ||
| ::: | ||
|
|
||
| ## Example usage | ||
|
|
||
| Configure an app mention trigger the same way you configure other trigger events: declare the event in `devvit.json`, map it to an internal endpoint, then handle requests at that endpoint. | ||
|
|
||
| ```json | ||
| "triggers": { | ||
| "onMentionInCommentCreate": "/internal/triggers/on-mention-in-comment-create" | ||
| } | ||
| ``` | ||
|
|
||
| Then handle the app mention trigger event in your server: | ||
|
|
||
| <Tabs | ||
| variant="pill" | ||
| groupId="http-server-framework" | ||
| defaultValue="hono" | ||
| values={[ | ||
| { label: 'Hono', value: 'hono' }, | ||
| { label: 'Express', value: 'express' }, | ||
| ]}> | ||
| <TabItem value="hono"> | ||
|
|
||
| ```tsx title="server/index.ts" | ||
| import type { | ||
| OnMentionInCommentCreateRequest, | ||
| TriggerResponse, | ||
| } from '@devvit/web/shared'; | ||
|
|
||
| app.post('/internal/triggers/on-mention-in-comment-create', async (c) => { | ||
| console.log('Handle event for on-mention-in-comment-create!'); | ||
| const input = await c.req.json<OnMentionInCommentCreateRequest>(); | ||
| const commentId = input.comment?.id; | ||
| console.log('Comment ID:', commentId); | ||
| return c.json<TriggerResponse>({ status: 'ok' }); | ||
| }); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="express"> | ||
|
|
||
| ```tsx title="server/index.ts" | ||
| import type { | ||
| OnMentionInCommentCreateRequest, | ||
| TriggerResponse, | ||
| } from '@devvit/web/shared'; | ||
|
|
||
| const router = express.Router(); | ||
|
|
||
| // .. | ||
|
|
||
| router.post<string, never, TriggerResponse, OnMentionInCommentCreateRequest>( | ||
| "/internal/triggers/on-mention-in-comment-create", | ||
| async (req, res) => { | ||
| console.log("Handle event for on-mention-in-comment-create!"); | ||
| const commentId = req.body.comment?.id; | ||
| console.log("Comment ID:", commentId); | ||
| res.status(200).json({ status: "ok" }); | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Playtesting app mention triggers | ||
|
|
||
| During development, you can playtest app mention trigger events only when the triggering event occurs in the playtest subreddit. Events from other subreddits do not invoke your app while you are playtesting. | ||
|
|
||
| ## Responding to app mention trigger events across Reddit | ||
|
|
||
| To receive app mention trigger events across Reddit, your app version must: | ||
|
|
||
| - Be published and approved. | ||
| - Be installed to the app's profile subreddit. | ||
|
|
||
| ## Profile subreddit installations | ||
|
|
||
| Some app versions can be installed to the app's profile subreddit. An app version is eligible when it has been approved and uses at least one app mention trigger event. | ||
|
|
||
| Eligible app versions appear in the **Profile installation** section of your app's settings page at [developers.reddit.com/apps/your-app-slug](https://developers.reddit.com/apps/your-app-slug). | ||
|
|
||
| ## Limitations | ||
|
|
||
| Apps do not receive app mention trigger events when: | ||
|
|
||
| - The event originates from a subreddit where the app is banned. | ||
| - The event does not pass safety checks, such as checks for illegal content. Events may contain NSFW content. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
versioned_docs/version-0.13/capabilities/server/global-triggers.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import Tabs from "@theme/Tabs"; | ||
| import TabItem from "@theme/TabItem"; | ||
|
|
||
| # App Mention Triggers | ||
|
|
||
| App mention triggers let your app respond to Reddit events even when those events happen outside the subreddit where your app is installed. App mention triggers are limited to app usernames. | ||
|
|
||
| Devvit currently supports one global trigger: `onMentionInCommentCreate` | ||
|
|
||
| :::note | ||
| This is a limited-access feature. Fill out this [form](https://docs.google.com/forms/d/e/1FAIpQLScLU2m-IH9xtt4hqFBNy5AlrswY0pvfvoyTiQREbq_9xDQJkQ/viewform) to request access. | ||
| ::: | ||
|
|
||
| ## Example usage | ||
|
|
||
| Configure an app mention trigger the same way you configure other trigger events: declare the event in `devvit.json`, map it to an internal endpoint, then handle requests at that endpoint. | ||
|
|
||
| ```json | ||
| "triggers": { | ||
| "onMentionInCommentCreate": "/internal/triggers/on-mention-in-comment-create" | ||
| } | ||
| ``` | ||
|
|
||
| Then handle the app mention trigger event in your server: | ||
|
|
||
| <Tabs | ||
| variant="pill" | ||
| groupId="http-server-framework" | ||
| defaultValue="hono" | ||
| values={[ | ||
| { label: 'Hono', value: 'hono' }, | ||
| { label: 'Express', value: 'express' }, | ||
| ]}> | ||
| <TabItem value="hono"> | ||
|
|
||
| ```tsx title="server/index.ts" | ||
| import type { | ||
| OnMentionInCommentCreateRequest, | ||
| TriggerResponse, | ||
| } from '@devvit/web/shared'; | ||
|
|
||
| app.post('/internal/triggers/on-mention-in-comment-create', async (c) => { | ||
| console.log('Handle event for on-mention-in-comment-create!'); | ||
| const input = await c.req.json<OnMentionInCommentCreateRequest>(); | ||
| const commentId = input.comment?.id; | ||
| console.log('Comment ID:', commentId); | ||
| return c.json<TriggerResponse>({ status: 'ok' }); | ||
| }); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="express"> | ||
|
|
||
| ```tsx title="server/index.ts" | ||
| import type { | ||
| OnMentionInCommentCreateRequest, | ||
| TriggerResponse, | ||
| } from '@devvit/web/shared'; | ||
|
|
||
| const router = express.Router(); | ||
|
|
||
| // .. | ||
|
|
||
| router.post<string, never, TriggerResponse, OnMentionInCommentCreateRequest>( | ||
| "/internal/triggers/on-mention-in-comment-create", | ||
| async (req, res) => { | ||
| console.log("Handle event for on-mention-in-comment-create!"); | ||
| const commentId = req.body.comment?.id; | ||
| console.log("Comment ID:", commentId); | ||
| res.status(200).json({ status: "ok" }); | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Playtesting app mention triggers | ||
|
|
||
| During development, you can playtest app mention trigger events only when the triggering event occurs in the playtest subreddit. Events from other subreddits do not invoke your app while you are playtesting. | ||
|
|
||
| ## Responding to app mention trigger events across Reddit | ||
|
|
||
| To receive app mention trigger events across Reddit, your app version must: | ||
|
|
||
| - Be published and approved. | ||
| - Be installed to the app's profile subreddit. | ||
|
|
||
| ## Profile subreddit installations | ||
|
|
||
| Some app versions can be installed to the app's profile subreddit. An app version is eligible when it has been approved and uses at least one app mention trigger event. | ||
|
|
||
| Eligible app versions appear in the **Profile installation** section of your app's settings page at [developers.reddit.com/apps/your-app-slug](https://developers.reddit.com/apps/your-app-slug). | ||
|
|
||
| ## Limitations | ||
|
|
||
| Apps do not receive app mention trigger events when: | ||
|
|
||
| - The event originates from a subreddit where the app is banned. | ||
| - The event does not pass safety checks, such as checks for illegal content. Events may contain NSFW content. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.