/chat-triggers/in/:chatId/message{{payload.message}}The same Chat Trigger can power a shared link, a website widget, an npm component and direct API calls at the same time.
Open the Chat Trigger in Flows
Sign in to hostwebhook.com and click Flows in the left sidebar. A Chat Trigger always comes with an AI node already connected, and both start paused. Click the Chat Trigger node to open its settings.
- Marker 1: The Chat Trigger receives each visitor message through its webhook.
- Marker 2: The AI node writes the reply. You configure it in step 6.
Starting from scratch? Add a Chat Trigger from the canvas (Nodes → build on the canvas). It arrives already connected to an AI node, just like this one.
Name and style the chat
The Set up your Chat Trigger window has three tabs. On Configuration, set what visitors see at the top of the chat. Changes save automatically; look for Saved in the top-right corner.
- Marker 1: Configuration, Advanced and Share & Activity hold every setting.
- Marker 2: Title and Subtitle appear in the chat header. This example uses “Support Assistant”.
- Marker 3: Don't click Activate yet. Turn it on after the AI node is ready (step 8).
Add a greeting and a persona
Scroll down the same tab. Set your brand color, add a greeting with + Add under Initial messages, and optionally give this chat its own persona.
- Marker 1: Primary color and Mode (dark, light or auto) style the widget.
- Marker 2: The greeting shows before the visitor types. It is display-only and is never sent to the AI.
- Marker 3: System prompt override replaces the AI node's system prompt for this chat only. Use it to run several bots with different personalities from one AI node.
Seeing “Not saved”?
An empty greeting row blocks saving. Type the greeting text, or click Remove on the empty row.
Set session and rate limits
Open the Advanced tab. Every message a visitor sends is a paid AI call, so these limits control your costs.
- Marker 1: The Advanced tab. Leave Session ID strategy on
autowhen you use the hosted link or widget. - Marker 2: Messages per minute defaults to 60 (range 1–600). For a public chat, a lower value such as 10–20 limits abuse.
- Marker 3: Per session is the recommended throttle bucket. Visitors behind the same office network don't share a limit.
Usage caps (further down) add hard daily and monthly limits on messages, tokens and dollars, and can email you at 75%, 90% and 100% of the monthly caps.
Choose who can use the chat
Scroll to the bottom of Advanced.
- Marker 1: Allowed origins lists the sites that may embed the chat, one per line, such as
https://yoursite.com. Leave it empty on a public chat to allow any site. - Marker 2: Public lets anyone with the link chat. HMAC signed only accepts requests signed by your own backend. Use it for logged-in users or paid tools.
Using HMAC signed?
- Allowed origins becomes required. If you also want the shared chat link to work, include the origin shown in your Share URL (step 10) along with your own site. Otherwise the link fails with a 403 error.
- Every request must be signed. Send an
Authorization: Bearer <sig>:<ts>header, wheresigis HMAC-SHA256 ofsessionId:tsusing the trigger's secret. The signature is valid for 5 minutes. - Keep the secret on your server and never put it in the browser. The widget gets signatures from a small signing endpoint you host. See the HostWebhook docs for examples in Node, Python and PHP.
Choose the AI provider
Click Done, then click the AI node in Flows (“Answers the chat …”) to open Set up your AI.
- Marker 1: Optional: Go to checklist adds guardrails (off-topic, PII, jailbreak rules). Recommended for public chats.
- Marker 2: Pick a provider: Anthropic, OpenAI, Google, Groq, OpenRouter or a self-hosted Ollama. This guide uses OpenAI.
Connect your API key and the visitor's message
Under Credential, click + Add OpenAI API Key (the button is named after your provider) and paste your key. Then fill in User message with {{payload.message}}, which is the text the visitor typed.
- Marker 1: A green Credential box means the key is connected. The key itself stays hidden.
- Marker 2:
{{payload.message}}sends the visitor's text to the AI.
- Marker 1: The System prompt sets the bot's default behaviour.
- Marker 2: Once you click away,
{{payload.message}}shows as a Message chip.
Where to get a key: OpenAI at platform.openai.com/api-keys, Anthropic at console.anthropic.com/settings/keys, Groq (free tier) at console.groq.com/keys. The provider account needs billing or credits set up, or replies will fail.
Activate both nodes
Click Activate at the top of the AI node, then reopen the Chat Trigger node and click Activate there too. Both badges should change from Paused to Active. A paused node ignores incoming messages.
- Marker 1: AI node: Active.
- Marker 2: Credential connected.
- Marker 1: Chat Trigger: Active.
- Marker 2: Preview widget opens a test chat (next step).
Test it in the preview
On the Chat Trigger's Configuration tab, click Preview widget. The real widget opens on the right. Send a message and watch the reply stream in.
- Marker 1: The live chat widget, using your title, subtitle and theme.
- Marker 2: Your greeting message.
- Marker 1: Your test message.
- Marker 2: The AI's reply, streamed back from the webhook.
A working preview doesn't prove the shared link works.
The dashboard preview skips the origin check. Always test the shared link too (next step), especially in HMAC signed mode.
Build your own customized chat UI
Optional · AdvancedMost people can stop at step 10. This step is only for developers who want their own chat interface, a mobile app or a backend integration instead of the ready-made widget.
Show how to call the webhook directly
Post to the Ingest endpoint from step 10. Send the visitor's message and a session ID you choose. Reuse the same session ID to continue a conversation.
curl -N -X POST \
https://api.hostwebhook.com/api/chat-triggers/in/YOUR_CHAT_ID/message \
-H "Content-Type: application/json" \
-d '{"message": "What are your opening hours?", "sessionId": "visitor-123"}'The reply streams back as Server-Sent Events:
event: session
data: {"sessionId":"visitor-123","hwsSessionId":"visitor-123"}
event: token
data: {"text":"We're open"}
event: token
data: {"text":" 9am to 5pm."}
event: done
data: {"response":"We're open 9am to 5pm.","conversationId":"…"}Signed trigger? Add the Authorization header described in step 5.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
| No reply at all | A node is paused, or the AI node has no credential. | Check that both nodes show Active and that the Credential box is green (steps 7–8). |
| “Not saved” | An empty greeting row. | Fill it in or click Remove. |
| 429 Too many messages | The rate limit was reached. | Wait for the Retry-After time, or raise Messages per minute (step 4). |
| 401 Invalid or missing signature | Signed trigger without a valid HMAC. | Sign sessionId:ts with the trigger secret; sign the session ID you send. |
| 403 on the shared link | Signed mode with an empty or incomplete Allowed origins list. | Add your site and the Share URL's origin to Allowed origins (step 5). |
| Chat stops for a visitor | A usage cap was reached. | Raise or clear the cap under Usage caps. Daily caps reset at UTC midnight. |