Skip to content

Rasa multiple responses not working with live chat #5

Open
@jersonjunior

Description

@jersonjunior

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions