Greeting based on user location

Hi All, Could you please help me to get greeting based on client time. Ex good morning and evening. How i can pass client ip to action

Hi @Neeraj,

I think one possible solution is to use the NLG module provided in the GitHub repository. In

First you could define a template with

    "utter_greet": [
      {
        "text": "[time], I want to greet you."
      },
      {
        "text": "[time] dear user, hello!"
      },
    ],

Then create a nlg server and in:

async def generate_response(nlg_call, domain):

resp = await TemplatedNaturalLanguageGenerator(domain.templates).generate(
        template, tracker, channel_name, **kwargs)

you could “catch” the resp[‘text’] attribute and replace [time] with the timezone calculated by any function implemented in nlg.py.

If you need help, feel free to ask!

Regards

Hi @JulianGerhard thanks for your response. I had created the api that is giving me ip address of client. Could you please help me how i should call this api in action , because if i am calling on action.py it is giving server ip not client. I need client ip adress if you have other idea to get the ip address of client please let me know. Thanks again !!

Hi @Neeraj,

okay - got it. I think a suitable way to achieve this is to implement an interface that both the rasa core server and your actions implement. I’d recommend a singleton pattern for this interface. According the Sanic documentation (which is preferred by rasa) you are able to read the requester IP easily:

https://sanic.readthedocs.io/en/latest/sanic/request_data.html

Set it in the interface and then you should be able to read it in every python file that implements the interface.

Regards

Hi @JulianGerhard thanks for response , still i am stucked. Can i sent ip address to tracker? . SO it will be easy to get on action server. I am using chatroom/scallable mind as recommended by rasa and rasa core version is rasa-core==0.11.12. Please help me i am stucked on this from week. Thanks & Regards

Hi @Neeraj

you could do that by adding a message to the tracker, though it is a bit “hacky”:

This relies on the flag --enable-api while running rasa. You then can be loop over the tracker and get the message and its information.

Does that help?

Hi @JulianGerhard as i can see there is only text and sender field. Where i have to add ip address?. Could you please provide example so i will help. Thank you :slight_smile:

Hi @souvikg10 @akelad do you have any idea how i can get client ip address in action.py . I want to created dynamic greeting based on client time and multilingual greeting based on client location. Please help me to get ip addres on action.py

@Neeraj is your query resolved? I am also looking for getting machine IP address data hence the question :slight_smile: