Running Python Code with Go Bot

Hi Im wondering if it is possible to execute python code for certain actions with the go_bot.
For example, let’s say someone asked what the weather was like and I wanted to make an API call with Python and return the result, is this possible?

Hi, yes it is.

You can add your python code in the __call__ method here (taking api_call_action as an example).

1 Like

Hi, Mary.

Let’s say I wanted to return a welcome message like “Hello” but from within the Python code, just as an example.
How easy is this to do? What do I need to add to run my own custom function that would return “Hello” and be displayed to the user?

Sorry for my lack of knowledge here!

You should replace the line with these lines:

if pred_act_id == WELCOME_MSG_ACTION_ID:
    resp = "Hello"
    # default mapping of action to response
    resp = self._decode_response(pred_act_id, state)

where WELCOME_MSG_ACTION_ID should be an index of a line in a templates files containing your desired action.

I am having the same question. However, the links in Mary’s reply no longer works.
Can you take another look at this problem?