(blink) Add redirect action

This commit is contained in:
Baptiste Arnaud 2025-10-20 11:15:00 +02:00
parent 7370298dd5
commit f5cfd684e1
No known key found for this signature in database
7 changed files with 98 additions and 11 deletions

View File

@ -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

View File

@ -22285,6 +22285,26 @@
"required": [
"action"
]
},
{
"type": "object",
"properties": {
"credentialsId": {
"type": "string"
},
"action": {
"type": "string",
"enum": [
"Redirect"
]
},
"url": {
"type": "string"
}
},
"required": [
"action"
]
}
]
}

View File

@ -13440,6 +13440,26 @@
"required": [
"action"
]
},
{
"type": "object",
"properties": {
"credentialsId": {
"type": "string"
},
"action": {
"type": "string",
"enum": [
"Redirect"
]
},
"url": {
"type": "string"
}
},
"required": [
"action"
]
}
]
}

View File

@ -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 {

View 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;
}`,
};
},
},
},
});

View File

@ -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",
});

View File

@ -138,7 +138,7 @@ export type ActionDefinition<
options: WithoutVariables<z.infer<BaseOptions> & z.infer<Options>>;
variables: VariableStore;
logs: LogsStore;
}) => FunctionToExecute;
}) => FunctionToExecute | undefined;
};
};
};