Feedback Actions
Update From Whatsapp Feedback Action
Explains the WhatsApp feedback action that runs when a WhatsApp message or call is received. Useful for conversational workflows, reply routing, media handling, answering WhatsApp calls with a voice assistant, and stubsession continuity.
Overview
When a Whatsapp message is received by the Stubber Platform the stubsession is derived to intelligently route the message to the correct stub.
Then the _update_from_whatsapp feedback action is triggered on the stub.
The _update_from_whatsapp feedback action is used to then further automate anything in the stub that needs to be done when a WhatsApp is received.
The message body of the Whatsapp message will be set to the message of the stubpost. i.e. stubpost.message.
If a contact can be derived from the mobile number of the sender, the posted_by => on_behalf_of will be set to the contact.
All the details of the Whatsapp message will be available in the stubpost.data._incoming_whatsapp_data data path.
WhatsApp calls to the number also trigger _update_from_whatsapp, see WhatsApp calls.
WhatsApp calls
When WhatsApp calling is enabled on the number, a call is routed to the stub the same way as a message, including the stubsession's feedback action, and triggers _update_from_whatsapp. Two flags on stubpost.data._incoming_whatsapp_data tell calls and messages apart:
The details of the call are in stubpost.data._incoming_whatsapp_data.call_data. Only two call events are posted: incoming and missed. Once a call is answered, the call reports back like any live voice call, with the _update_from_voice feedback action, including when it ends.
Add stubpost.data._incoming_whatsapp_data.is_call_event != true to the conditions of tasks that handle messages, eg a GPT Chat Task that replies to the user. Otherwise they also run for calls, and treat "Incoming WhatsApp call" as something the user typed.
Answering a call
Run Start Voice Chat with the whatsapp channel, then Answer WhatsApp Call with the call and the new voice session. Use is_incoming_call as the condition on both:
answer_whatsapp_call returns once the caller hears the assistant, usually within 2 seconds, or with an error when answering failed:
The call must be answered within 25 seconds of the incoming event, otherwise it's rejected automatically and a missed event follows.
To end an answered call, end the voice call as usual, eg with a hangup voice notification.
Rejecting a call
To not take the call, run Reject WhatsApp Call:
It only works while the call is ringing. A missed event with the reason rejected follows.
Missed calls
A call that was never answered triggers _update_from_whatsapp a second time, with call_data.event set to missed and is_incoming_call set to false. Use it to follow up, eg send a WhatsApp message saying you missed the call:
call_data.reason says why the call was missed:
Call data
Example data for an incoming call:
Example data for a missed call:
Call properties
is_call_event boolean
true for every call event. Not set for messages.
is_incoming_call boolean
true for a ringing call to answer or reject, false for a missed call. Not set for messages.
call_data.event string
incoming or missed.
call_data.comwhatsappcalluuid string
The id of the call. Pass it to answer_whatsapp_call or reject_whatsapp_call.
call_data.call_id string
WhatsApp's id for the call.
call_data.from_user_id string
WhatsApp's business-scoped id for the caller. Always set, even when from is missing because the caller uses a WhatsApp username.
call_data.direction string
USER_INITIATED: the WhatsApp user called the business.
call_data.cta_payload string
The payload of the call button the caller used, if the call came from a call button in a message. Otherwise null.
call_data.deeplink_payload string
The payload of the call link the caller used, if the call came from a call deeplink. Otherwise null.
call_data.timestamp string
Unix timestamp of the call event.
call_data.answer_deadline string
incoming only. The ISO 8601 date-time by which the call must be answered.
call_data.reason string
missed only. Why the call was missed: caller_hangup, rejected or answer_timeout.
Data Structure
Feedback Action Data
Example data that is passed to the _update_from_whatsapp feedback action:
JSONSchema
The JSONSchema of the stubpost.data._incoming_whatsapp_data is :