Template Guidelines
Message Flow
Explains how a message travels between a notification platform, the _create and default contexts and the LLM, and how stubsessions route replies.
A typical agent conversation is facilitated by the Stubber Platform using the built-in communication platforms (notification platforms), stubsessions and the template contexts.
The Whatsapp example below is typical of how every notification platform works.
First message
- A message is sent to a Whatsapp number that is configured on a Whatsapp profile in Stubber.
- The Whatsapp integration uses the profile to look up the stubref of the stub to trigger the feedback action on. This is typically a
_createcontext stub. - The integration triggers
_update_from_whatsappon that stub.stubpost.messageis the incoming message text, andstubpost.dataholds information about the message, including the from number and profile name. - The
_update_from_whatsappaction on the_createcontext has a task that creates a newdefaultcontext stub and passes all the data into it. - The new
defaultcontext stub triggers the_createlifecycle action when it is created. - The
_createaction has agpt_chat_taskthat initializes the LLM chat with a system message, and might inject the Whatsapp message as a user role message.
Reply from the LLM
- The task submits to the specified LLM model. When the reply is received, the
_update_from_chat_assistant_taskfeedback action is triggered, withstubpost.messageset to the reply. _update_from_chat_assistant_taskhas a notification that sends a Whatsapp message to the incoming number, with the message set to the reply from the LLM.- The notification also sets a new stubsession on the incoming Whatsapp number, with a timeout in hours:
Conversational loop
- When the user replies, the Whatsapp integration sees the active stubsession and triggers
_update_from_whatsappdirectly on thedefaultcontext stub. - The
_update_from_whatsappaction on thedefaultcontext has agpt_chat_taskthat relays the incoming message to the LLM chat. - The user and the LLM can now chat over Whatsapp. Each outgoing message resets the stubsession timeout another 24 hours into the future (or more if set otherwise).
Summary
- Initial messages trigger a feedback action on a
_createcontext stub. - A
defaultcontext stub is created per conversation. - A
gpt_chat_taskon the platform's feedback action passes the user message to the LLM. - The
_update_from_chat_assistant_taskaction routes notifications back out on the relevant platform. - The stubsession set on outgoing notifications routes later replies straight to the
defaultcontext stub.