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

Twilio send_custom_json tries to set from attribute instead of from_ #5277

Closed
nbeuchat opened this issue Feb 20, 2020 · 3 comments · Fixed by #5281
Closed

Twilio send_custom_json tries to set from attribute instead of from_ #5277

nbeuchat opened this issue Feb 20, 2020 · 3 comments · Fixed by #5281
Assignees
Labels
type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@nbeuchat
Copy link
Contributor

Rasa version: 1.7.0

Python version: 3.7

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

Issue:
I am just testing the capabilities of the Twilio connector and when sending a custom json_message, it throws an error as it tries to set the from attribute instead of the from_ attribute.

Error (including full traceback):

[2020-02-20 15:18:23 +0100] [11856] [ERROR] Exception occurred while handling uri: 'http://570158816806510.ngrok.io/webhooks/twilio/webhook'
Traceback (most recent call last):
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/sanic/app.py", line 942, in handle_request
    response = await response
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/channels/twilio.py", line 132, in message
    metadata=metadata,
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/channels/channel.py", line 83, in handler
    await app.agent.handle_message(*args, **kwargs)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/agent.py", line 486, in handle_message
    return await processor.handle_message(message)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/processor.py", line 108, in handle_message
    await self._predict_and_execute_next_action(message.output_channel, tracker)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/processor.py", line 509, in _predict_and_execute_next_action
    action, tracker, output_channel, self.nlg, policy, confidence
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/processor.py", line 620, in _run_action
    await self._send_bot_messages(events, tracker, output_channel)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/processor.py", line 549, in _send_bot_messages
    await output_channel.send_response(tracker.sender_id, e.message())
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/channels/channel.py", line 189, in send_response
    await self.send_custom_json(recipient_id, message.pop("custom"), **message)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/channels/twilio.py", line 70, in send_custom_json
    await self._send_message(json_message)
  File "/home/nicolas/anaconda3/envs/chatbot_sms/lib/python3.7/site-packages/rasa/core/channels/twilio.py", line 37, in _send_message
    message = self.messages.create(**message_data)
TypeError: create() got an unexpected keyword argument 'from'

Command or request that led to error:

dispatcher.utter_message(json_message={
            "body": "Hello! Here is a cat",
            "media_url": "https://i.ytimg.com/vi/uHKfrz65KSU/maxresdefault.jpg"
        })

The problem is that the send_custom_json has a mistake here. It tries to set json_message.setdefault("from", self.twilio_number) instead of json_message.setdefault("from_", self.twilio_number)

Content of configuration file (config.yml) (if relevant): Clone of Sara-bot

Content of domain file (domain.yml) (if relevant): Clone of Sara-bot

@nbeuchat nbeuchat added the type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. label Feb 20, 2020
@erohmensing
Copy link
Contributor

@nbeuchat thanks for tracking down the bug, would you be willing to open a PR with the fix?

@nbeuchat
Copy link
Contributor Author

Sure, happy to do so! Probably the shortest PR ever ;-)

@erohmensing
Copy link
Contributor

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants