From c58ed8bd2c7d67c4b9c26ad51f9b231a0523c0be Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 16 Aug 2022 11:43:51 -0500 Subject: [PATCH] personal followup email --- functions/src/create-user.ts | 3 ++- functions/src/emails.ts | 41 +++++++++++++++++++++++++++++++++++- functions/src/send-email.ts | 6 ++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/functions/src/create-user.ts b/functions/src/create-user.ts index bd65b14a..c0b03e23 100644 --- a/functions/src/create-user.ts +++ b/functions/src/create-user.ts @@ -16,7 +16,7 @@ import { cleanDisplayName, cleanUsername, } from '../../common/util/clean-username' -import { sendWelcomeEmail } from './emails' +import { sendPersonalFollowupEmail, sendWelcomeEmail } from './emails' import { isWhitelisted } from '../../common/envs/constants' import { CATEGORIES_GROUP_SLUG_POSTFIX, @@ -96,6 +96,7 @@ export const createuser = newEndpoint(opts, async (req, auth) => { await addUserToDefaultGroups(user) await sendWelcomeEmail(user, privateUser) + await sendPersonalFollowupEmail(user, privateUser) await track(auth.uid, 'create user', { username }, { ip: req.ip }) return { user, privateUser } diff --git a/functions/src/emails.ts b/functions/src/emails.ts index 19c7d4e4..710ecab1 100644 --- a/functions/src/emails.ts +++ b/functions/src/emails.ts @@ -1,3 +1,5 @@ +import * as dayjs from 'dayjs' + import { DOMAIN } from '../../common/envs/constants' import { Answer } from '../../common/answer' import { Bet } from '../../common/bet' @@ -14,7 +16,7 @@ import { import { getValueFromBucket } from '../../common/calculate-dpm' import { formatNumericProbability } from '../../common/pseudo-numeric' -import { sendTemplateEmail } from './send-email' +import { sendTemplateEmail, sendTextEmail } from './send-email' import { getPrivateUser, getUser } from './utils' import { getFunctionUrl } from '../../common/api' import { richTextToString } from '../../common/util/parse' @@ -165,6 +167,43 @@ export const sendWelcomeEmail = async ( ) } +export const sendPersonalFollowupEmail = async ( + user: User, + privateUser: PrivateUser +) => { + if (!privateUser || !privateUser.email) return + + const { name } = user + const firstName = name.split(' ')[0] + + const emailBody = `Hi ${firstName}, + +Thanks for signing up! I'm one of the cofounders of Manifold Markets, and was wondering how you've found your exprience on the platform so far? + +If you haven't already, I encourage you to try creating your own prediction market (https://manifold.markets/create) and joining our Discord chat (https://discord.com/invite/eHQBNBqXuh). + +Feel free to reply to this email with any questions or concerns you have. + +Cheers, + +James +Cofounder of Manifold Markets +https://manifold.markets + ` + + const sendTime = dayjs().add(4, 'hours').toString() + + await sendTextEmail( + privateUser.email, + 'How are you finding Manifold?', + emailBody, + { + from: 'James from Manifold ', + 'o:deliverytime': sendTime, + } + ) +} + export const sendOneWeekBonusEmail = async ( user: User, privateUser: PrivateUser diff --git a/functions/src/send-email.ts b/functions/src/send-email.ts index 7a643418..cb054aa7 100644 --- a/functions/src/send-email.ts +++ b/functions/src/send-email.ts @@ -9,10 +9,12 @@ const initMailgun = () => { export const sendTextEmail = async ( to: string, subject: string, - text: string + text: string, + options?: Partial ) => { const data: mailgun.messages.SendData = { - from: 'Manifold Markets ', + ...options, + from: options?.from ?? 'Manifold Markets ', to, subject, text,