cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAI : Convert External service response to quick reply or List?

former_member25214
Participant
0 Kudos

Greeting Community,

I am want to create a list or (quick response) from the values I get from external response, so that user can choose from them. Is it possible to do that?

For Example :

Select the processor from below list:

1. AMD Ryzen 5

2. Intel i9

3. AMD Ryzen 8

...

This is the list that comes in the response from external services.

Hope I am clear on the question I have.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

There is now a new message type called "Custom", where you can use JSON to pre-defined specify message types and include scripting and references to your API response to do what you want.

https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/ad3681adae824f8a96cbcf8b88...

former_member25214
Participant
0 Kudos

Thanks for sharing, I just saw this feature today. I found one issue when using that "Custom" type, I choose the carousel reply but its not working as it shown in the documentation or the tutorial video on this link => https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/ad3681adae824f8a96cbcf8b88...

When using the postback button type it does not postback the value I have saved, instead it gives me the Title in the reply, another thing i notices is that the carousel is closing(minimising) automatically.

I'm not sure if its a bug or am I doing something wrong here, sharing the screenshot for reference.


Any help would be great.

Thanks.

former_member715858
Participant
0 Kudos

Good Day Daniel ,

I am facing some issue to filter the json file response, how to debug , can I get a list of all support format please

can I share the code to check .

Regards

Dan_Wroblewski
Developer Advocate
Developer Advocate

1) Please open a new question -- you can reference this one if that is helpful.

2) I am now following you so you send me a mail.

Looking forward to your challenge 🙂

former_member715858
Participant
0 Kudos

Hi Daniel,

A question is already asked on the community under this link

https://answers.sap.com/questions/13213465/consume-and-filter-rest-api-file.html

can you text me directly so I can elaborate more about the case and share with you what i achieved so far .

Regards,

Answers (1)

Answers (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

Once you get the JSON response, it goes into api_service_request, so you can set the quick reply button texts to something like this {{api_service_response.myresponse.body.text}} or whatever depending on the format of your JSON and what you set the response namespace to in the API widget.

Just remember if quick replies isn't the last message in your response to the user, the quick replies are not displayed.

former_member25214
Participant
0 Kudos

Hi Daniel,

Thanks for the reply, I wanted to know how to show populate the list of data from api to quick reply, as the number of items are not fixes i can't hard code the number of quick reply or list item.

Is there a way to apply a for each loop on the api response and get the data displayed on chat bot so that user can select from given choices and I can take the action based on selection.

Dan_Wroblewski
Developer Advocate
Developer Advocate

Ah, I see. I believe there may be a feature planned to enable this more easily. In the meantime, you would have to create a webhook, which would then iterate the list and return the quick reply. This is described here: https://developers.sap.com/tutorials/conversational-ai-webhook-api-call.html

This documentation shows how to format the response to create "rich" controls, like quick replies so you could create a quick reply for each iteration: https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/75174bf0017548fa86d602f227...