cancel
Showing results for 
Search instead for 
Did you mean: 

Webhook Call Response

Raiaan
Explorer
0 Kudos

How can I access the response from a webhook call within SAP CAI?

View Entire Topic
dtephan
Participant
0 Kudos

The webhook response will directly be added to the bot response. The replies will be added to the messages and the conversation node will impact memory and language. More details can be found here.

If you want to use an API where the response needs to be transformed or only parts of the response should be used in further actions please refer to "consume API service" action.

Raiaan
Explorer
0 Kudos

Let's say I retrieve a count of items from a webhook call, say 5. If I now want to send a text message to the user that says "You have 5 items in your inventory" what is the syntax to access that webhook response value (5)?

dtephan
Participant
0 Kudos

Webhooks need to match the following response structure:

{
  "replies": [
    {
      "type": "text",
      "content": "Hello world!"
    }
  ],
  "conversation": {
    "language": "en",
    "memory": {
      "user": "Bob"
    }
  }
}

If the API called in your case does not match this structure "Consume API service" needs to be used instead of Webhook. The response of Consume API Service can be accessed with {{api_service_response}} afterwards.

Raiaan
Explorer
0 Kudos

I'm using a middleware so I need to use a webhook. My response looks like this

What's the syntax to access the "content" within CAI?