Rasa: How to send and receive message per sender_id?

Created on 22 May 2018  路  3Comments  路  Source: RasaHQ/rasa

Rasa Core version:
Current version from master (0.9.0a6)

Python version:
3.6

Operating system (windows, osx, ...):
OSx

Issue:
I have trained the NLU and dialog model. Now I run them as a server using
$python -m rasa_core.server -d models/dialogue -u models/nlu/default/customernlu/ --debug -o out.log --cors *

And from another terminal, I use the below CURL command to get reply

$curl -XPOST localhost:5005/conversations/default/respond -d '{"query":"Hello"}'

Which works fine with below reply:
[{"recipient_id":"default","text":"Hello! How can I help?"}]

Now I need to send message per sender id - assuming many chat clients are accessing the server. So I used the sender_id parameter in the CURL command

curl -XPOST localhost:5005/conversations/default/respond -d '{"sender_id":"me","query":"Hello"}'

But the agent is still interpreting this message as a message from default sender_id.

[{"recipient_id":"default","text":"Hello! How can I help?"}]

What am I missing? My dialogue management model training code below:

def train_dialogue(domain_file = 'customer_domain.yml',
                    model_path = './models/dialogue',
                    training_data_file = './data/stories.md'):

    agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy()])

    agent.train(
                training_data_file,
                epochs = 300,
                batch_size = 50,
                validation_split = 0.2)

    agent.persist(model_path)
    return agent

Content of domain file (if used & relevant):


Most helpful comment

In Rasa HTTP server, sender_id is a URL route parameter, rather than a POST body parameter. Your HTTP request should look like this if you want sender_id to be me:

curl -XPOST localhost:5005/conversations/me/respond -d '{"query":"Hello"}'

Please see how respond() is defined for Rasa HTTP server here.

All 3 comments

In Rasa HTTP server, sender_id is a URL route parameter, rather than a POST body parameter. Your HTTP request should look like this if you want sender_id to be me:

curl -XPOST localhost:5005/conversations/me/respond -d '{"query":"Hello"}'

Please see how respond() is defined for Rasa HTTP server here.

Resolved with @LawnboyMax technique

In Rasa HTTP server, sender_id is a URL route parameter, rather than a POST body parameter. Your HTTP request should look like this if you want sender_id to be me:

curl -XPOST localhost:5005/conversations/me/respond -d '{"query":"Hello"}'

Please see how respond() is defined for Rasa HTTP server here.

Hi @LawnboyMax I had the same issue and thanks for giving the solution. But I want to save this sender_id in my rasa actions.py file as I want to run an API call again in a custom action and get other details from a DB. So after putting a HTTP request how can SAVE this sender_id in rasa.? Please help me with this issue! any help is appreciated. <3

Was this page helpful?
0 / 5 - 0 ratings