Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rasa multiple responses not working with live chat #5

Open
jersonjunior opened this issue Jun 21, 2022 · 0 comments
Open

Rasa multiple responses not working with live chat #5

jersonjunior opened this issue Jun 21, 2022 · 0 comments

Comments

@jersonjunior
Copy link

jersonjunior commented Jun 21, 2022

It's only returning a single-line response. I made a change in the code to return multiple lines but without buttons

Original Code - rasa_flask_router.py:

def send_to_bot(sender, message):
    data = {
        'sender': sender,
        'message': message
    }
    headers = {"Content-Type": "application/json",
               "Accept": "application/json"}

    r = requests.post(f'{rasa_url}/webhooks/rest/webhook',
                      json=data, headers=headers)
    return r.json()[0]['text']

My Code:

def send_to_bot(sender, message):
    data = {
        'sender': sender,
        'message': message
    }
    headers = {"Content-Type": "application/json",
               "Accept": "application/json"}

    r = requests.post(f'{rasa_url}/webhooks/rest/webhook',
                      json=data, headers=headers)
    print(r.text)
    resposta = json.loads(r.text)
    #print(resposta)
    resposta_final = ''
    for x in resposta:
        for y in x.keys():
            if y != 'text':
                continue
            resposta_final += (x['text']) + '\n'
    print(resposta_final)
    return resposta_final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant