Skip to main content

Ask Salesloft

This package is for interacting with the Ask Salesloft sidebar.

AskSalesloftContext​

The AskSalesloftContext stores contextual information for rendering the sidebar and submitting prompts to the AI. See the AskSalesloftContext type for details.

Modifying the AskSalesloftContext​

To modify the AskSalesloftContext from any React component, simply use the useAskSalesloftContext hook, providing a middleware that modifies the context as needed.

caution

This middleware will only be applied as long as the component is mounted.

  import { useAskSalesloftContext } from '@shared/ask-salesloft'

useAskSalesloftContext((context) => {
context.suggestedPrompts.add('This is a sample suggested prompt')
context.suggestedPrompts.add('Here is another sample suggested prompt')
context.welcomeMessage = 'This is a sample welcome message'
context.agentContext.someField = 'someValue'
})

Outside React​

To modify the AskSalesloftContext outside of the React runtime, use addMiddleware and removeMiddleware.

// When the context is relevant:
const removeMiddleware = addMiddleware(() => {
context.suggestedPrompts.add('This is a sample suggested prompt')
context.suggestedPrompts.add('Here is another sample suggested prompt')
context.welcomeMessage = 'This is a sample welcome message'
context.agentContext.someField = 'someValue'
})

// When the context is no longer relevant:
removeMiddleware()

Open the Ask Salesloft sidebar​

caution

Make sure to modify the AskSalesloftContext prior to opening the sidebar.

import { startNewChat } from '@shared/ask-salesloft'

startNewChat()

Send a prompt on behalf of the user​

caution

Make sure to modify the AskSalesloftContext prior to sending any prompts.

import { sendPrompt } from '@shared/ask-salesloft'

sendPrompt('This is a sample prompt')