Spooner AI x Guru Integration Automation Template
from models import AllowedEmail
import os
from guru_api import httpx
import hashlib
import logging
from datetime import datetime, timedelta
from typing import Optional, List, Dict
import asyncio
from flask import session as flask_session
from flask import Flask, request, jsonify, render_template, abort
from flask_cors import CORS
from sqlalchemy.orm import Session
from abilities import apply_sqlite_migrations, flask_app_authenticator
from models import Base, engine, CronJob, GuruAPI, LinkedAssistant, AllowedDomain
from cron_manager import start_cron_manager
from settings import runtime_app_settings
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = Flask(__name__)
app.secret_key = os.environ.get('FLASK_SECRET_KEY', 'supersecretkey')
Frequently Asked Questions
How can the Spooner X Guru Integration Automation benefit my business?
The Spooner X Guru Integration Automation can significantly enhance your business's knowledge management and customer support capabilities. By seamlessly connecting your Guru knowledge base with your Spooner AI assistant, you ensure that your AI has access to the most up-to-date information from your Guru cards. This integration allows for more accurate and consistent responses to customer inquiries, reducing the workload on your support team and improving overall customer satisfaction.
Is it possible to schedule automatic updates with this integration?
Yes, the Spooner X Guru Integration Automation includes a feature for scheduling automatic updates. You can set up cron jobs to periodically sync your Guru cards with your Spooner assistant. This ensures that your AI always has the latest information without manual intervention. To schedule an update, you can use the "Schedule Automatic Updates" button in the interface, which allows you to select specific collections and set the update interval in hours.
How does this integration handle access control and security?
The Spooner X Guru Integration Automation implements robust access control measures. It includes features for managing allowed email addresses and domains, ensuring that only authorized personnel can access and manage the integration. This is crucial for maintaining the security of your knowledge base and preventing unauthorized access to sensitive information.
How can I add custom validation to the modal dialogs in this template?
The template includes a custom modal system that allows for easy addition of validation logic. Here's an example of how you can add custom validation to a modal:
javascript
showCustomModal("Enter a value greater than 10", {
showInput: true,
inputType: 'number',
customValidation: function() {
const value = parseInt(document.querySelector('#customModal input').value);
if (value <= 10) {
alert("Please enter a value greater than 10");
return false;
}
return { value: value };
}
}).then(result => {
if (result) {
console.log("Valid input:", result.value);
}
});
This code creates a modal that asks for a number input and validates that it's greater than 10 before closing.
How does the Spooner X Guru Integration Automation handle the conversion of Guru cards to a format suitable for Spooner?
The integration automatically converts Guru cards to a format that Spooner can understand. Here's a snippet from the send_cards_to_spooner
function that demonstrates this process:
```python for card in cards: card_id = card.get("id") if not card_id: continue
# Convert HTML content to markdown
markdown_content = guru_client.convert_cards_to_markdown([card])[0].get('markdown_content', '')
url_data = {
"url": f"guru://{card_id}",
"assistant_id": assistant_id,
"preferredPhrase": card.get("preferredPhrase", ""),
"content": card.get("content", ""),
"source_sitemap": "guru",
"markdown_content": markdown_content,
"pagetype": "Guru Knowledge Card"
}
urls_data.append(url_data)
```
This code processes each Guru card, converts its HTML content to markdown, and structures the data in a format that Spooner can ingest and use effectively.
Created: | Last Updated:
Here's a step-by-step guide for using the Spooner X Guru Integration Automation template:
Introduction
This template allows you to integrate your Guru Cards with your Spooner Assistant. It provides functionality to send Guru cards to Spooner, schedule automatic updates, and manage allowed emails and domains for access control.
Getting Started
- Click "Start with this Template" to begin using the Spooner X Guru Integration Automation template in Lazy.
Initial Setup
Before running the app, you need to set up the following environment secrets:
- Open the Environment Secrets tab in the Lazy Builder.
- Add the following secrets:
GURU_EMAIL
: Your Guru account emailGURU_TOKEN
: Your Guru API tokenFLASK_SECRET_KEY
: A secure random string for Flask session encryption
To obtain your Guru API token: 1. Log in to your Guru account 2. Go to Settings > API & Integrations 3. Generate a new API token
Test the App
- Click the "Test" button to deploy and run the app.
- Wait for the deployment to complete and the Lazy CLI to appear.
Using the App
Once the app is running, you'll be provided with a URL to access the web interface. Open this URL in your browser to interact with the Spooner X Guru Integration Automation app.
The main features of the app include:
- Sending Guru Cards to Spooner
- Scheduling automatic updates
- Managing allowed emails and domains for access control
Linking Your Spooner Assistant
Before you can send cards to Spooner, you need to link your Spooner Assistant:
- Follow the steps in the documentation to link your Guru to Spooner.
- Once linked, you'll be able to use the "Send Guru Cards to Spooner" and "Schedule Automatic Updates" features.
Sending Guru Cards to Spooner
- Click the "Send Guru Cards to Spooner" button.
- In the modal that appears, select the Guru collections you want to send to Spooner.
- Click "Send" to initiate the transfer.
Scheduling Automatic Updates
- Click the "Schedule Automatic Updates" button.
- In the modal, set the update interval (in hours).
- Select the Guru collections you want to include in the automatic updates.
- Click "Schedule" to create the cron job.
Managing Access Control
The app allows you to manage access by adding or removing allowed emails and domains:
- To add an allowed email, enter the email address in the "Enter email address" field and click "Add Email".
- To remove an allowed email, click the trash icon next to the email in the list.
- To add an allowed domain, enter the domain (e.g., "getlazy.ai") in the "Enter domain" field and click "Add Email Domain".
- To remove an allowed domain, click the trash icon next to the domain in the list.
Integrating the App
This app runs as a standalone web application. To integrate it with your existing systems:
- Use the provided URL to access the web interface.
- Ensure that your Guru and Spooner accounts are properly configured and linked.
- Set up the necessary access control by adding allowed emails or domains.
- Use the app's features to send Guru cards to Spooner and schedule automatic updates as needed.
Remember to keep your environment secrets (GURU_EMAIL, GURU_TOKEN, and FLASK_SECRET_KEY) secure and up-to-date for the app to function correctly.
Here are 5 key business benefits for this Spooner X Guru integration template:
Template Benefits
-
Automated Knowledge Syncing: Seamlessly synchronize Guru knowledge cards with your Spooner AI assistant, ensuring your AI always has access to the latest company information and policies.
-
Improved Customer Support: Empower your AI assistant with up-to-date knowledge from Guru, enabling faster and more accurate responses to customer inquiries across various channels.
-
Enhanced Employee Onboarding: Provide new employees with an AI assistant that can instantly answer questions about company processes, policies, and best practices, accelerating the onboarding process.
-
Centralized Knowledge Management: Maintain a single source of truth in Guru while automatically propagating that knowledge to your AI assistant, reducing information silos and inconsistencies.
-
Increased Productivity: Save time and resources by automating the process of updating your AI assistant's knowledge base, allowing your team to focus on creating and curating content rather than manual updates.