✨ Add Segment block (#1672)
Added support for Twilio Segment New Segment Block added to Forge. Includes the following: - Credentials - Identify User, including Traits - Alias User - Track Event, including Properties - Track Bot View ( Page ), including Properties - Generate UUID for User IDs Tested integration with Segment, verified working. Uses Segment's NodeJS analytics library to support non-browser based platforms, such as WhatsApp --------- Co-authored-by: John Walsh <john@famkit.com> Co-authored-by: Baptiste Arnaud <baptiste.arnaud95@gmail.com>
This commit is contained in:
38
packages/forge/blocks/segment/actions/alias.ts
Normal file
38
packages/forge/blocks/segment/actions/alias.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { createAction, option } from '@typebot.io/forge'
|
||||
import { Analytics } from '@segment/analytics-node'
|
||||
import { auth } from '../auth'
|
||||
|
||||
export const alias = createAction({
|
||||
auth,
|
||||
name: 'Alias',
|
||||
options: option.object({
|
||||
userId: option.string.layout({
|
||||
label: 'User ID',
|
||||
isRequired: true,
|
||||
moreInfoTooltip: 'New ID of the user.',
|
||||
}),
|
||||
previousId: option.string.layout({
|
||||
label: 'Previous ID',
|
||||
moreInfoTooltip: 'Previous ID of the user to alias.',
|
||||
}),
|
||||
}),
|
||||
run: {
|
||||
server: async ({
|
||||
credentials: { apiKey },
|
||||
options: { userId, previousId },
|
||||
}) => {
|
||||
if (!userId || userId.length === 0
|
||||
|| !previousId || previousId.length === 0
|
||||
|| apiKey === undefined) return
|
||||
|
||||
const analytics = new Analytics({ writeKey: apiKey })
|
||||
|
||||
analytics.alias({
|
||||
userId: userId,
|
||||
previousId: previousId
|
||||
})
|
||||
|
||||
await analytics.closeAndFlush()
|
||||
}
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user