which clientMessage should I use to send simple te...
# support
g
Lets say I want the user to type his email in frontend and send it to assistant that can be acheived using vapi.send() in websdk The issue is I want to trigger that UI pop-up when they are about to book appointment. There are many clientMessages and I am not sure which is best for such an interaction. All I need is the assistant able to report with certain enums some custom states of call it is asked to report on to client, for example send "ask_email" client message when needed. That is when we can trigger front end to pop-up the text box and send back the email using vapi.send() This can be a failed empty tool call, but that is clunky as hell. Is there a better way to send specific event triggers to frontend?
v
You can use client-side events to trigger UI pop-ups instead of failed empty tool calls. Listen for the
message
event in your frontend code:
Copy code
javascript
vapi.on("message", (message) => {
  // Check if message contains your custom state
  if (message.content && message.content.includes("ask_email")) {
    // Trigger your UI pop-up for email input
    showEmailPopup();
  }
});
Then have your assistant include the trigger text in its response when appropriate. Sources: - [Vapi SDK Documentation](https://docs.vapi.ai/sdks) - [Discord Discussion](https://discord.com/channels/1211482211119796234/1330803502615625738)
g
@Vapi Support Bot how do I configure the assistant to send the ask_email message
v
To configure your assistant to send the "ask_email" message, modify the system prompt in your assistant configuration:
Copy code
javascript
// Update your assistant via API
curl -X PATCH https://api.vapi.ai/assistant/YOUR_ASSISTANT_ID \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
  "model": {
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant. When the user is about to book an appointment, include the text 'ask_email' in your response."
      }
    ]
  }
}'
This instructs the assistant to include the trigger text that your frontend code is listening for. Source: - [Vapi Knowledge Base](https://docs.vapi.ai/knowledge-base)
g
@Vapi Support Bot But which clientMessage is it? that is going to send ask_email to my client? it can't be transcript as assistant would SAY ask_email which we don't want, give me a clientMessage that is for this
@Shubham Bajaj Please guide me
@Sahil maybe you could guide me better?
v
Based on the information available, I can see you're looking for a specific clientMessage type to send custom triggers without them being spoken. Have you tried using the
tool-calls
clientMessage type? This might allow you to send structured data to your frontend without it being part of the spoken transcript. Could you share more details about your current assistant configuration and how you're handling clientMessages in your frontend code? Sources: - [Vapi SDK Documentation](https://docs.vapi.ai/sdks) - [Discord Discussion](https://discord.com/channels/1211482211119796234/1330803502615625738)
g
@Vapi Support Bot I already said empty failed tool calls could be a solution, but I am asking if something better exists.
v
Try using the
add-message
type with
vapi.send()
and set
triggerResponseEnabled
to false:
Copy code
javascript
vapi.send({
  type: "add-message",
  message: {
    role: "system",
    content: "ask_email"
  },
  triggerResponseEnabled: false
});
Then listen for system messages in your frontend code to trigger the email popup without the assistant speaking it. Sources: - [Vapi Background Messages](https://docs.vapi.ai/assistants/background-messages) - [Discord Discussion](https://discord.com/channels/1211482211119796234/1338730919904673853)
s
@GeneralKugelBlitz could you provide more context about your specific use case? To help effectively, I'd need to understand: 1. What's the complete flow you're trying to implement? 2. What solutions have you already tried? 3. Why didn't those solutions work for your needs? 4. Any specific constraints your solution must satisfy?
@GeneralKugelBlitz The more details you can share about your implementation goals, the better I can assist you.
I tried understanding your current problem but couldn't get aligned with it properly, so yeah I need your more help.
g
No issue, let me write in detail.
Objective: send custom event/state messages only for front-end to trigger actions in the browser Possible solutions: an empty tool call or one with a specific message Drawbacks: quite clunky to scale Ideal-scenario: custom messages like "speech-start" etc you already send but defined by us The goal for this is not a tool call flow that asks something in return, the goal is to update front-end based on where the call is and send custom messages to front-end for it to change its state example: an avatar emotion and gesture state outputs from a certain list of enums so front end avatar could be sad, happy, shocked as it is speaking.
Is that possible?
s
You can trigger async tool calls from your assistant, did you tried this?
2 Views