AI Copilot Tools
Section titled “AI Copilot Tools”YourGPT AI Copilot transforms your chatbot into a powerful AI agent capable of performing complex tasks and making intelligent decisions. Here are the key tools available in the AI Copilot:
1. AI Actions
Section titled “1. AI Actions”AI Actions allow your copilot to perform specific tasks in your application through custom-defined functions. These actions can be triggered based on user intent and can include user confirmations for critical operations.
2. Code Execution
Section titled “2. Code Execution”The Code Execution tool enables your AI Copilot to safely execute code within your application environment. This feature is perfect for:
- Running data analysis scripts
- Performing calculations
- Generating dynamic content
- Testing code snippets
3. API Integration
Section titled “3. API Integration”The API Integration tool allows your AI Copilot to interact with external services and APIs. Key capabilities include:
- Making HTTP requests to external services
- Handling API authentication
- Processing API responses
- Error handling and retries
4. Web Search
Section titled “4. Web Search”The Web Search tool empowers your AI Copilot to gather real-time information from the internet. Features include:
- Real-time web searches
- Content summarization
- Source verification
- Safe search filtering
SDK Integration
Section titled “SDK Integration”Web SDK Integration
Section titled “Web SDK Integration”import { YourGPT } from "@yourgpt/widget-web-sdk";
// Initialize the SDKawait YourGPT.init({ widgetId: "your-widget-id",});
React SDK Integration
Section titled “React SDK Integration”import { YourGPT, useYourGPTChatbot, useAIActions } from "@yourgpt/widget-web-sdk/react";
// Initialize in your main app file (main.tsx or App.tsx)YourGPT.init({ widgetId: "your-widget-id",});
AI Actions Implementation
Section titled “AI Actions Implementation”Using Web SDK
Section titled “Using Web SDK”import { YourGPT } from "@yourgpt/widget-web-sdk";
// Initialize the SDKawait YourGPT.init({ widgetId: "your-widget-id",});
// Register an AI Actionconst copilot = YourGPT.getInstance();
copilot.registerAIAction("create_user_account", async (data, helpers) => { const confirmed = await helpers.confirm({ title: "Create Account", description: "Would you like to create an account with the provided details?" });
if (confirmed) { // Execute account creation logic const result = await createAccount(data.userDetails); helpers.respond(`Account created successfully for ${result.name}!`); }});
Using React Hooks
Section titled “Using React Hooks”import { useAIActions } from "@yourgpt/widget-web-sdk/react";
function AIActionsComponent() { const aiActions = useAIActions();
useEffect(() => { // Register multiple actions at once aiActions.registerActions({ get_time: async (data, helpers) => { helpers.respond(`Current time: ${new Date().toLocaleString()}`); }, get_page_url: async (data, helpers) => { helpers.respond(`Current URL: ${window.location.href}`); }, take_screenshot: async (data, helpers) => { const confirmed = await helpers.confirm({ title: "Screenshot", description: "Take a screenshot of the current page?", });
if (confirmed) { // Screenshot logic using html2canvas or similar helpers.respond("Screenshot taken successfully"); } }, });
// Cleanup on unmount return () => { aiActions.unregisterAction("get_time"); aiActions.unregisterAction("get_page_url"); aiActions.unregisterAction("take_screenshot"); }; }, [aiActions]);
return ( <div> <h3>Registered AI Actions</h3> <p>Count: {aiActions.registeredActions.length}</p> <ul> {aiActions.registeredActions.map((action) => ( <li key={action}>{action}</li> ))} </ul> </div> );}
Resources
Section titled “Resources”For more examples and detailed documentation, check out our resources:
- YourGPT Web SDK Repository - Official SDK repository with documentation and source code
- Pre-built Examples - Collection of ready-to-use example implementations