Real time API call

Hi there,

I’m creating an assistant which should be able to inform me about my services in real time. For this to work I created a REST API, which provides information in json format. The API will only provide new information whenever it is called (it does not push data).

The API works perfectly with other products and also works in Python. However, it does not work when calling it in an action with the assistant. It calls up on the API whenever the action server is started. It keeps this state and provides me with information that isnt real time.

Is there a possibility to call up on an API after the action server is started?

Hi @Andre, yes you can run the API call in a custom action any time it’s invoked. Could you please also share you code so that I am sure I understood correctly what you are trying to do?

1 Like

Hi there @EPedrotti. Sorry i didnt recieve a notification from your response. So i’m calling on one of our own API’s (json format) which provideds me with realtime information about our services (How many customers, which phonenumers/mailadress, who are they talking to etc).

I’m using the ‘request’ package in python and the following to get the data:

#queueapi = requests.get('https://this_is_a_fake_api/{}/queue'.format(servicename))
    for queue in queueapi.json():
    			x = queue["AgentsOnCall"]
    			Agentsoncall += x

servicename would be a slot filled by Rasa.

After calling the API i’m just itterating over the JSON file to get to what i want. Not sure if it efficient, but within python it does the job quick and correct. Everytime i run the code within my notebook, it gets the current information. But whenever i let the bot call it, it will just give me the information from the time the action server went live.

Please let me know what code / information i should provide you . your help is greatly appriciated :slight_smile: :slight_smile: