chatwoot / chatwoot/implementation-examples

Rasa multiple responses not working with live chat

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
38
Forks
12
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.