When a chatbot needs to keep its own conversation transcript, a webhook can update it automatically as the conversation unfolds. A webhook is an API call triggered by a predefined event. In a chatbot’s orchestration layer, it can run before or after the bot processes a user response and can use conversational context. section 12.2.2
For example, a post-webhook can add each user message and bot reply to a transcript, one message per line. The transcript can be a string, array, JSON object, or custom object. Platform terminology and the required format vary, so check the platform’s documentation before implementing one. section 12.2.2
Listing 12.3 Pseudocode for a webhook that updates a transcript
def transcript_webhook(request, response):
userMessage = request.input.text #1
botMessage = response.output.text #2
if(userMessage != null) #3
response.context.transcript += 'User: ' + #4
userMessage + '\n'
if(botMessage != null)
response.context.transcript += 'Bot: ' +
botMessage + '\n'
The pseudocode shows a post-webhook adding available user and bot messages to the transcript. section 12.2.2





