mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-05 21:04:43 +08:00
✨ (blink) Add redirect action
This commit is contained in:
parent
7370298dd5
commit
f5cfd684e1
@ -54,7 +54,6 @@ The "Send Feed Event" action allows you to create rich, interactive cards in you
|
||||
|
||||
The Blink integration supports a rich variety of content types for your feed cards. For comprehensive UI options and examples, refer to the [official Blink CardKit documentation](https://developer.joinblink.com/docs/cardkit).
|
||||
|
||||
|
||||
### Targeting
|
||||
|
||||
- **User IDs**: Specific users who should see this feed event
|
||||
|
||||
@ -22285,6 +22285,26 @@
|
||||
"required": [
|
||||
"action"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"credentialsId": {
|
||||
"type": "string"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Redirect"
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"action"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -13440,6 +13440,26 @@
|
||||
"required": [
|
||||
"action"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"credentialsId": {
|
||||
"type": "string"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Redirect"
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"action"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -181,15 +181,17 @@ export const executeForgedBlock = async (
|
||||
const clientSideActions: ExecuteIntegrationResponse["clientSideActions"] = [];
|
||||
|
||||
if (action?.run?.web?.parseFunction) {
|
||||
clientSideActions.push({
|
||||
type: "codeToExecute",
|
||||
codeToExecute: action?.run?.web?.parseFunction({
|
||||
credentials: credentialsData ?? {},
|
||||
options: parsedOptions,
|
||||
variables,
|
||||
logs: logsStore,
|
||||
}),
|
||||
const codeToExecute = action?.run?.web?.parseFunction({
|
||||
credentials: credentialsData ?? {},
|
||||
options: parsedOptions,
|
||||
variables,
|
||||
logs: logsStore,
|
||||
});
|
||||
if (codeToExecute?.content)
|
||||
clientSideActions.push({
|
||||
type: "codeToExecute",
|
||||
codeToExecute,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
45
packages/forge/blocks/blink/src/actions/redirect.ts
Normal file
45
packages/forge/blocks/blink/src/actions/redirect.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { createAction, option } from "@typebot.io/forge";
|
||||
import { auth } from "../auth";
|
||||
|
||||
export const redirect = createAction({
|
||||
name: "Redirect",
|
||||
auth,
|
||||
options: option.object({
|
||||
url: option.string.optional().layout({
|
||||
label: "URL",
|
||||
placeholder: "https://app.joinblink.com/#/hub/xxxx-xxxx",
|
||||
}),
|
||||
}),
|
||||
run: {
|
||||
web: {
|
||||
parseFunction({ options: { url } }) {
|
||||
return {
|
||||
args: {
|
||||
url: url ?? null,
|
||||
},
|
||||
content: `
|
||||
if (!url) return;
|
||||
const idMatch = url?.match(/([a-f0-9-]{36})$/);
|
||||
if (!idMatch) return;
|
||||
|
||||
const action = \`blink:folder?action=open&id=\${idMatch[1]}\`;
|
||||
try {
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openClientAction) {
|
||||
window.webkit.messageHandlers.openClientAction.postMessage(action);
|
||||
} else if (window.android && typeof window.android.openClientAction === 'function') {
|
||||
window.android.openClientAction(action);
|
||||
} else if (window.parent && window.parent !== window) {
|
||||
console.log("posting message to parent");
|
||||
window.parent.postMessage({ functionName: 'openClientAction', args: [action] }, document.referrer);
|
||||
} else {
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}`,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -1,5 +1,6 @@
|
||||
import { createBlock } from "@typebot.io/forge";
|
||||
import { getUsers } from "./actions/getUsers";
|
||||
import { redirect } from "./actions/redirect";
|
||||
import { sendFeedEvent } from "./actions/sendFeedEvent";
|
||||
import { auth } from "./auth";
|
||||
import { BlinkLogo } from "./logo";
|
||||
@ -10,6 +11,6 @@ export const blinkBlock = createBlock({
|
||||
tags: ["CRM", "HR"],
|
||||
LightLogo: BlinkLogo,
|
||||
auth,
|
||||
actions: [getUsers, sendFeedEvent],
|
||||
actions: [getUsers, sendFeedEvent, redirect],
|
||||
docsUrl: "https://docs.typebot.io/editor/blocks/integrations/blink",
|
||||
});
|
||||
|
||||
@ -138,7 +138,7 @@ export type ActionDefinition<
|
||||
options: WithoutVariables<z.infer<BaseOptions> & z.infer<Options>>;
|
||||
variables: VariableStore;
|
||||
logs: LogsStore;
|
||||
}) => FunctionToExecute;
|
||||
}) => FunctionToExecute | undefined;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user