personal followup email

This commit is contained in:
mantikoros 2022-08-16 11:43:51 -05:00
parent c3eaf0351b
commit c58ed8bd2c
3 changed files with 46 additions and 4 deletions

View File

@ -16,7 +16,7 @@ import {
cleanDisplayName, cleanDisplayName,
cleanUsername, cleanUsername,
} from '../../common/util/clean-username' } from '../../common/util/clean-username'
import { sendWelcomeEmail } from './emails' import { sendPersonalFollowupEmail, sendWelcomeEmail } from './emails'
import { isWhitelisted } from '../../common/envs/constants' import { isWhitelisted } from '../../common/envs/constants'
import { import {
CATEGORIES_GROUP_SLUG_POSTFIX, CATEGORIES_GROUP_SLUG_POSTFIX,
@ -96,6 +96,7 @@ export const createuser = newEndpoint(opts, async (req, auth) => {
await addUserToDefaultGroups(user) await addUserToDefaultGroups(user)
await sendWelcomeEmail(user, privateUser) await sendWelcomeEmail(user, privateUser)
await sendPersonalFollowupEmail(user, privateUser)
await track(auth.uid, 'create user', { username }, { ip: req.ip }) await track(auth.uid, 'create user', { username }, { ip: req.ip })
return { user, privateUser } return { user, privateUser }

View File

@ -1,3 +1,5 @@
import * as dayjs from 'dayjs'
import { DOMAIN } from '../../common/envs/constants' import { DOMAIN } from '../../common/envs/constants'
import { Answer } from '../../common/answer' import { Answer } from '../../common/answer'
import { Bet } from '../../common/bet' import { Bet } from '../../common/bet'
@ -14,7 +16,7 @@ import {
import { getValueFromBucket } from '../../common/calculate-dpm' import { getValueFromBucket } from '../../common/calculate-dpm'
import { formatNumericProbability } from '../../common/pseudo-numeric' import { formatNumericProbability } from '../../common/pseudo-numeric'
import { sendTemplateEmail } from './send-email' import { sendTemplateEmail, sendTextEmail } from './send-email'
import { getPrivateUser, getUser } from './utils' import { getPrivateUser, getUser } from './utils'
import { getFunctionUrl } from '../../common/api' import { getFunctionUrl } from '../../common/api'
import { richTextToString } from '../../common/util/parse' 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 <james@manifold.markets>',
'o:deliverytime': sendTime,
}
)
}
export const sendOneWeekBonusEmail = async ( export const sendOneWeekBonusEmail = async (
user: User, user: User,
privateUser: PrivateUser privateUser: PrivateUser

View File

@ -9,10 +9,12 @@ const initMailgun = () => {
export const sendTextEmail = async ( export const sendTextEmail = async (
to: string, to: string,
subject: string, subject: string,
text: string text: string,
options?: Partial<mailgun.messages.SendData>
) => { ) => {
const data: mailgun.messages.SendData = { const data: mailgun.messages.SendData = {
from: 'Manifold Markets <info@manifold.markets>', ...options,
from: options?.from ?? 'Manifold Markets <info@manifold.markets>',
to, to,
subject, subject,
text, text,