Greeting based on user location - Rasa Open Source - Rasa Community Forum

Greeting based on user location

post by Neeraj on Jun 7, 2019

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?

post by JulianGerhard on Jun 7, 2019

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

post by Neeraj on Jun 7, 2019

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 address if you have other idea to get the ip address of client please let me know. Thanks again !!

post by JulianGerhard on Jun 8, 2019

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 to 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

post by Neeraj on Jun 13, 2019

Hi @JulianGerhard thanks for response, still I am stuck. Can I send 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

post by JulianGerhard on Jun 13, 2019

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?

post by Neeraj on Jun 13, 2019

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

post by Neeraj on Jul 5, 2019

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

post by lelemh on Aug 17, 2020

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