From 4c0ba1bd5b9c8e83b10aed892e19ad367c4b6071 Mon Sep 17 00:00:00 2001 From: MarconLP <13001502+MarconLP@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:54:58 +0200 Subject: [PATCH] add discord template --- frontend/public/services/discord.png | Bin 0 -> 8242 bytes posthog/cdp/templates/__init__.py | 2 + .../cdp/templates/discord/template_discord.py | 64 ++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 frontend/public/services/discord.png create mode 100644 posthog/cdp/templates/discord/template_discord.py diff --git a/frontend/public/services/discord.png b/frontend/public/services/discord.png new file mode 100644 index 0000000000000000000000000000000000000000..d21ba297b0d9ce50a5af7e3ea8cf3fbc91cb4f25 GIT binary patch literal 8242 zcmc(kXEYp8wC_g{B%(wwA#q0duD9Noch1_M&iQbD=j^rjfA4cMdovG+01*8D9yi?pYEnQbAe4}R z18|3$fRLKtrjMWy03aa#ucHC}_aL}KNJM;>gp};weJa2m0z$$&M1;h|L`1hcKi{qa zh^UDlJ`q#AOQUN;!U3Wc|B_rl%BfV_L#H=};gYcZ6h?NBo`I2xnVW}~k6%Di>e+K? z8Cm7mDynL4)HU=C42_IUOwH`<9X>cZIlFjzdHeYK`3HnYL`Fr&#Kxthrln_m|B;zh zSX2xyfs~e&*VQ+`8k?G1T6^Jri2i|JgTKcoCa0!nX6KNrDD>L;#^%=c&e8G7>Dl=O z_TMD|fbhR>`oDnw4<71Uo;yTDghV9&$wP3*_tprhiHM(w-F>L2OJW0};Sm2qN~@Gy zP}@VsDWQjs5(1^&LVI+ITwhv#go>-my!6{u_L-W8RtLTigq2i-_p6H3 z8`Ge#zfbw7ssMAfO3~uFnqA4*?u@pTqh5U;y3g+1 zFex<|c4e4EY^hKyIs8roY(gob;(1w%f#XSeD~HJ$@|o~2ktV--pXV!LZB|W1=lsc! z*dJo+T%G1>kL%&9uvz$p-kWT#V6py?H##JK6krSazyT(UlY9JEZ>t6LM?sj<{0{z}-91UJ{jZ&cH^m*bP;jV_$fX<=l8Ww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XOH>0rs7z=~$0#7h#%!<+r{o_i&`y_y73oj)JN_$CAY-K$rQR=9S%i?5 zO^y#5meE2aJGrv4FyDKWFJIwG3%hLF@Xp+>QcTi|7wtgk+5Y&nTwqh1J8W+s+*&XYCN23oOd6taXX*a+)D|#s55TT%r^^0Si_8CZUFY8 ziCH9li{gS%{oWbp8vyA=U()^gUv%x7D{b>J;I^nK`{c*?`7y@?scOpM7sZ;T=J%hc z2%29FFIVKVcCEApb9E(Ns9xs=({+b>?x;hMALPmEafsY|(ei?;<^GMHkv(HQ&65b*(iO39aBWYx!JitF zfQB;kj?Lt{MpmDUZZ3tH)V2{sJI!WyolC0UH1}>IB(@RP3M-$-8Um(jLaR$} Y`^?LQV@?@EbrS#cr)^=V!p+=&0B^E96951J literal 0 HcmV?d00001 diff --git a/posthog/cdp/templates/__init__.py b/posthog/cdp/templates/__init__.py index 1d982a7fdd199..915c4d119530f 100644 --- a/posthog/cdp/templates/__init__.py +++ b/posthog/cdp/templates/__init__.py @@ -8,6 +8,7 @@ from .clearbit.template_clearbit import template as clearbit from .posthog.template_posthog import template as posthog, TemplatePostHogMigrator from .aws_kinesis.template_aws_kinesis import template as aws_kinesis +from .discord.template_discord import template as discord from .salesforce.template_salesforce import template_create as salesforce_create, template_update as salesforce_update from .mailjet.template_mailjet import ( template_create_contact as mailjet_create_contact, @@ -43,6 +44,7 @@ braze, clearbit, customerio, + discord, engage, gleap, google_ads, diff --git a/posthog/cdp/templates/discord/template_discord.py b/posthog/cdp/templates/discord/template_discord.py new file mode 100644 index 0000000000000..576324ef21e4a --- /dev/null +++ b/posthog/cdp/templates/discord/template_discord.py @@ -0,0 +1,64 @@ +from posthog.cdp.templates.hog_function_template import HogFunctionTemplate, HogFunctionSubTemplate, SUB_TEMPLATE_COMMON + +template: HogFunctionTemplate = HogFunctionTemplate( + status="beta", + id="template-discord", + name="Discord", + description="Sends a message to a discord channel", + icon_url="/static/services/discord.png", + category=["Customer Success"], + hog=""" +let res := fetch(inputs.webhookUrl, { + 'body': inputs.content, + 'method': 'POST', + 'headers': { + 'Content-Type': 'application/json' + } +}); + +if (res.status != 200 or not res.body.ok) { + throw Error(f'Failed to post message to Discord: {res.status}: {res.body}'); +} +""".strip(), + inputs_schema=[ + { + "key": "webhookUrl", + "type": "string", + "label": "Webhook URL", + "description": "See this page on how to generate a Webhook URL: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks", + "secret": False, + "required": True, + }, + { + "key": "content", + "type": "json", + "label": "Content", + "description": "(see https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline)", + "default": {"content": "**{person.name}** triggered event: '{event.event}'"}, + "secret": False, + "required": True, + }, + ], + sub_templates=[ + HogFunctionSubTemplate( + id="early_access_feature_enrollment", + name="Post to Discord on feature enrollment", + description="Posts a message to Discord when a user enrolls or un-enrolls in an early access feature", + filters=SUB_TEMPLATE_COMMON["early_access_feature_enrollment"].filters, + inputs={ + "content": { + "content": "**{person.name}** {event.properties.$feature_enrollment ? 'enrolled in' : 'un-enrolled from'} the early access feature for '{event.properties.$feature_flag}'" + }, + }, + ), + HogFunctionSubTemplate( + id="survey_response", + name="Post to Discord on survey response", + description="Posts a message to Discord when a user responds to a survey", + filters=SUB_TEMPLATE_COMMON["survey_response"].filters, + inputs={ + "content": {"content": "**{person.name}** responded to survey **{event.properties.$survey_name}**"}, + }, + ), + ], +)