Skip to content

Learn · Tutorials

Tutorial: guard a chatbot

One guard call between your users and your bot.

Put one check between your users and your chatbot. Before the bot answers, ask the guard whether the message is safe; you get allow, take a look, or block — with a plain reason.

Wrap the call

from dmzagent import Client

client = Client(api_key="YOUR_API_KEY")
verdict = client.guard(
    deployment="YOUR_DEPLOYMENT_ID",
    message=user_message,
)
if verdict.allowed:
    reply = your_bot(user_message)

Placeholder values shown. Signed-in users see their real key.

Handle the three answers

  • Allow — answer normally.
  • Take a look — answer carefully, or route to a person.
  • Block — do not answer; show your safe reply with the reason.

Every check is written to your logbook, so you can show exactly what was asked, what the guard said, and what your bot did. A denying state always fails safe to block.