Skip to content

Commit

Permalink
feat: Add new hook for retrieving bot id
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Oct 5, 2024
1 parent 4ce2596 commit 334029e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/hooks/internal/useBotIdInternal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useBotRefsContext } from "../../context/BotRefsContext";

/**
* Internal custom hook for managing bot id.
*/
export const useBotIdInternal = () => {
// handles bot refs
const { botIdRef } = useBotRefsContext();

/**
* Retrieves the id for the chatbot.
*/
const getBotId = () => {
return botIdRef.current;
}

return {
getBotId
};
}
13 changes: 13 additions & 0 deletions src/hooks/useBotId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useBotIdInternal } from "./internal/useBotIdInternal";

/**
* External custom hook for managing bot id.
*/
export const useBotId = () => {
// handles bot id
const { getBotId } = useBotIdInternal();

return {
getBotId
};
}

0 comments on commit 334029e

Please sign in to comment.