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')

Send artifacts with a prompt​

An artifact is an object the agent edits across turns, such as a play. Put the current artifacts in the store; sendPrompt sends them in the /invoke body (only when the list is not empty) and replaces them with the artifacts in each successful response. startNewChat and loading another session clear them. A response or session load never replaces artifacts set after its request started. The content is opaque to this package.

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

setArtifacts([
{ type: 'play', id: 'play-1', schema_version: 1, content: { name: 'My play' } },
])
sendPrompt('Rename the play')