|
1 | | -import { Wrench, GitBranch } from '@phosphor-icons/react/dist/ssr'; |
| 1 | +import { CheckSquare, Wrench, GitBranch } from '@phosphor-icons/react/dist/ssr'; |
2 | 2 | import Link from 'next/link'; |
3 | 3 | import Alert from '@/components/Alert'; |
4 | 4 |
|
@@ -90,5 +90,73 @@ Call any external API using a HTTP request. |
90 | 90 |
|
91 | 91 | ## Examples |
92 | 92 |
|
93 | | -Examples TBA. |
| 93 | +### Discord |
| 94 | + |
| 95 | +Cross-post your topics to a Discord channel using a <a href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks" target="_blank">Discord Webhook</a>. |
| 96 | + |
| 97 | +- **Name**: News to Discord |
| 98 | +- **Enabled**: <CheckSquare /> |
| 99 | +- **Trigger**: Doctrine: Persist |
| 100 | +- **Entity**: `Forumify\Forum\Entity\Topic` |
| 101 | +- **Condition**: Expression |
| 102 | +- **Expression**: `entity.getForum().getSlug() == 'news'` |
| 103 | + - You can find the slug of a forum by visiting it in a browser. *https://example.org/forum/* **this-part-here**, |
| 104 | +- **Webhook URL**: https://discord.com/api/webhooks/*id*/*token* |
| 105 | + - Use the **Copy Webhook URL** button after creating a webhook in Server Settings -> Integrations -> Webhooks -> New Webhook. |
| 106 | +- **Data**: Something compatible with <a href="https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params">Discord's webhook execution format</a>. For example an embed: |
| 107 | +```twig |
| 108 | +{{ { |
| 109 | + embeds: [ |
| 110 | + { |
| 111 | + title: entity.title, |
| 112 | + description: entity.firstComment.content|html_to_markdown({ |
| 113 | + strip_tags: true, |
| 114 | + hard_break: true, |
| 115 | + header_style: 'atx', |
| 116 | + remove_nodes: 'img', |
| 117 | + })|u.truncate(4000, '...', false), |
| 118 | + url: absolute_url(path('forumify_forum_topic', { slug: entity.slug })), |
| 119 | + } |
| 120 | + ] |
| 121 | +}|json_encode|raw }} |
| 122 | +``` |
| 123 | + |
| 124 | +You can do even more, like prefixing it with a message that includes a link to the forum and the author: |
| 125 | + |
| 126 | +```twig |
| 127 | +{% set user = entity.createdBy %} |
| 128 | +{% set userLink = '[' ~ user.displayName ~ '](' ~ absolute_url(path('forumify_forum_profile', { username: user.username })) ~ ')' %} |
| 129 | +{% set forumLink = '[' ~ entity.forum.title ~ '](' ~ absolute_url(path('forumify_forum_forum', { slug: entity.forum.slug })) ~ ')' %} |
| 130 | +{{ { |
| 131 | + content: userLink ~ ' just posted a new topic in ' ~ forumLink, |
| 132 | + embeds: [...] |
| 133 | +}|json_encode|raw }} |
| 134 | +``` |
| 135 | + |
| 136 | +### Zapier |
| 137 | + |
| 138 | +Zapier allows you to build incredibly complex automation workflows with tons of templates. Like creating Facebook posts, sending emails, asking ChatGPT, insert into a spreadsheet,... |
| 139 | + |
| 140 | +You can use forumify automations as a trigger for a Zapier workflow. |
| 141 | + |
| 142 | +- **Name**: Events To Zapier |
| 143 | +- **Enabled**: <CheckSquare /> |
| 144 | +- **Trigger**: Doctrine: Persist |
| 145 | +- **Entity**: `Forumify\Calendar\Entity\CalendarEvent` |
| 146 | +- **Condition**: Expression |
| 147 | +- **Expression**: `entity.getCalendar().getSlug() == 'workshops'` |
| 148 | + - You can find the slug of a calendar by visiting it in a browser. *https://example.org/calendar/* **this-part-here**, |
| 149 | +- **Webhook URL**: https://hooks.zapier.com/hooks/catch/*id1*/*id2*/ |
| 150 | + - When you create a Zapier **Catch Hook** trigger, it will automatically generate a Webhook URL for you to use. |
| 151 | +- **Data**: The format for Zapier isn't strict so we just give it the fields we want to use. |
| 152 | +```twig |
| 153 | +{{ { |
| 154 | + title: entity.title, |
| 155 | + start: entity.start|date('Y-m-d H:i:s'), |
| 156 | + content: entity.content, |
| 157 | + calendar: entity.calendar.title |
| 158 | +}|json_encode|raw }} |
| 159 | +``` |
| 160 | + |
| 161 | +If you trigger the automation at least once, your data will become available in Zapier's UI and you can build the rest of your workflow there. |
94 | 162 |
|
0 commit comments