cancel
Showing results for 
Search instead for 
Did you mean: 

Can we modify both the bot memory and send a reply to the client in one request?

octavian
Advisor
Advisor
0 Kudos

Hello!

Is there a way to add bot replies and alter bot memory to a conversation outside of the webhook flow?
Meaning I need to do these operations in one request and SAP CAI hasn't initiated the request.

I know of
PUT URL_PREFIX/build/v1/users/$USER_SLUG/bots/$BOT_SLUG/versions/$VERSION_SLUG/builder/conversation_states/$CONVERSATION_ID and
POST URL_PREFIX/connect/v1/conversations/$CONVERSATION_ID/messages

Is there a way to do this in one api call? I would like to avoid the possibility that one request succeeds and 1 fails leaving the bot state in an inconsistent manner.

EDIT:
I've tried the /dialog api and here are some quirks, each of them is unacceptable:
- all messages sent to /dialog will be considered client sent and not bot replies.
- all messages send to /dialog will be nlp/builder processed, resulting in actions pinging backends changing state and producing other replies.
- all messages and replies from /dialog will not be sent to the chat as the bot connector did not proxy these calls and is not aware of them.

As a result using the /dialog api is a side-effect inducing way of setting just the bot's memory.

Thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

Are you saying you want to use the CAI API? Can't you use the dialog endpoint and send whatever memory information you want?

https://reverseproxy.cai.tools.sap/docs/api-reference/#dialog-endpoints

The call has a request parameter for memory.

octavian
Advisor
Advisor
0 Kudos

Thank you for your quick response.
Yes indeed I need to use the API.

I've tried the /dialog api and here are some quirks, each of them is unacceptable:
- all messages sent to /dialog will be considered client sent and not bot replies.
- all messages send to /dialog will be nlp/builder processed, resulting in actions pinging backends changing state and producing other replies.
- all messages and replies from /dialog will not be sent to the chat as the bot connector did not proxy these calls and is not aware of them.

As a result this is only a side-effect way of setting just the bot's memory.

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Can you explain the real-life scenario a little more? Do you mean you want to talk with the chatbot user because of other things happening outside the chatbot -- like a notification about some outside world event -- and just send a message to the user without any regard for the NLP or Builder (except to manually update the memory)?

I'm not an expert or part of the chatbot team, but it seems slightly not a basic scenario to have conversations that last more than a few back and forths, or to just keep the chatbot window open in case of messages from the chatbot ... but I assume I don't really understand the use case.

octavian
Advisor
Advisor
0 Kudos

Sorry for the late reply, apparently never received a notification :).

Your description of what I wanted is spot on.

Consider the user is waiting in a support queue, position updates / support technician replies may come at any point later without user interaction.
Our idea was to implement a "fallback channel" as recast puts it but with another provider than those currently available.

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Just thinking out loud, but for updating the memory, couldn't you define your own intent which triggers a skill that will update the memory (or the API will update the memory). The only real side effect I see is it would affect the skill stack, but I'm not sure this is actually true because your skill would be added to the stack but also be executed so the stack probably stays the same.

For creating a kind of real-time messaging service to the chatbot, I don't see that built in. But you could in the web page send a message to the bot, like "Display message" and that would trigger your skill which would retrieve the message and display it. A little weird since it would show as if the user sent the message (I assume) but it would work.