digiteinfotech/kairon

Api action

masoudMZB opened this issue · 2 comments

Hello all
how can I create an API action? I don't see any doc or any example for it

I get this error :

The fields "{'headers'}" do not exist on the document "HttpActionConfig"

I have this simple get request https://61e13d1463f8fc0017618ac5.mockapi.io/test/akbar
and the response will be :

{
"key_test": "value_test"
}

I have one Rule which I want to use this api action. So which fields Should I fill.
in api action there are : Action name | request_type | Headers | Body | Response
How should I fill these parts

Hi @masoudMZB,
Apologies that you had to face this issue. It would be great if you can share steps to recreate this issue.
From your requirements, I am sharing a screenshot of an API action i created.
image

The bot response in this case will be the API output.
We expect a placeholder in the response field to fit your api response into. Users can either get complete response with ${RESPONSE} placeholder or a custom placeholder based on the api response.

image
The bot response in above case will be: Response from api is value_test.

There maybe cases where our api output has list elements. For this, we can have list indices along with keys as our placeholder.
Eg: If my api output is:

{
    'temperature': [
        {
            'date': '14-Jan',
            'temp': 23,
            'unit': 'Celcius'
        },
        {
            'date': '13-Jan',
            'temp': 25,
            'unit': 'Celcius'
        },
        {
            'date': '12-Jan',
            'temp': 24,
            'unit': 'Celcius'
        }
    ]
}

and I want my bot to respond with: Temperature on 14-Jan is 23 degree celcius.
I will create my API action as shown below:
image

Hope, this will be helpful. Please reach out in case you need further help.

thanks for your answer this was the exact answer. I'll close this issue