Skip to content

Commit

Permalink
Send chat message to Khoj web app via url query param
Browse files Browse the repository at this point in the history
- This allows triggering khoj chat from the browser addressbar
- So now if you add Khoj to your browser bookmark with
  - URL: https://app.khoj.dev/?q=%s
  - Keyword: khoj

- Then you can type "khoj what is the news today" to trigger Khoj to
  quickly respond to your query. This avoids having to open the Khoj web
  app before asking your question
  • Loading branch information
debanjum committed Sep 18, 2024
1 parent ecdbcd8 commit bb2bd77
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/interface/web/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { getIconFromIconName } from "@/app/common/iconUtils";
import { AgentData } from "@/app/agents/page";
import { createNewConversation } from "./common/chatFunctions";
import { useIsMobileWidth } from "./common/utils";
import { useSearchParams } from "next/navigation";

interface ChatBodyDataProps {
chatOptionsData: ChatOptions | null;
Expand Down Expand Up @@ -51,6 +52,14 @@ function ChatBodyData(props: ChatBodyDataProps) {
const [agentIcons, setAgentIcons] = useState<JSX.Element[]>([]);
const [agents, setAgents] = useState<AgentData[]>([]);
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
const searchParams = useSearchParams();
const queryParam = searchParams.get("q");

useEffect(() => {
if (queryParam) {
setMessage(decodeURIComponent(queryParam));
}
}, [queryParam]);

const onConversationIdChange = props.onConversationIdChange;

Expand Down

0 comments on commit bb2bd77

Please sign in to comment.