Vapi SDK lets you silently update the chat history through efficient text message integration. This is particularly useful for background tasks or discreetly logging user interactions.
Add a Button to Trigger the Message
onClick
event handler that will call a function to send the system message:Log the Action as a System Message
logUserAction
function will silently insert a system message into the chat history:vapi.send
: The primary function to interact with your assistant, handling various requests or commands.type: "add-message"
: Specifies the command to add a new message.message
: This is the actual message that you want to add to the message history.
role
: “system” Designates the message origin as ‘system’, ensuring the addition is unobtrusive. Other possible values of role are ‘user’ | ‘assistant’ | ‘tool’ | ‘function’content
: The actual message text to be added.