rasa.core.channels.channel
UserMessage Objects
Represents an incoming message.
Includes the channel the responses should be sent to.
__init__
Creates a UserMessage
object.
Arguments:
text
- the message text content.output_channel
- the output channel which should be used to send bot responses back to the user.sender_id
- the message owner ID.parse_data
- rasa data about the message.input_channel
- the name of the channel which received this message.message_id
- ID of the message.metadata
- additional metadata for this message.
register
Registers input channel blueprints with Sanic.
InputChannel Objects
Input channel base class.
name
Every input channel needs a name to identify it.
blueprint
Defines a Sanic blueprint.
The blueprint will be attached to a running sanic server and handle incoming routes it registered for.
get_output_channel
Create OutputChannel
based on information provided by the input channel.
Implementing this function is not required. If this function returns a valid
OutputChannel
this can be used by Rasa to send bot responses to the user
without the user initiating an interaction.
Returns:
OutputChannel
instance or None
in case creating an output channel
only based on the information present in the InputChannel
is not
possible.
get_metadata
Extracts additional information from the incoming request.
Implementing this function is not required. However, it can be used to extract
metadata from the request. The return value is passed on to the
UserMessage
object and stored in the conversation tracker.
Arguments:
request
- incoming request with the message of the user
Returns:
Metadata which was extracted from the request.
decode_jwt
Decodes a Bearer Token using the specific JWT key and algorithm.
Arguments:
bearer_token
- Encoded Bearer tokenjwt_key
- Public JWT key for decoding the Bearer tokenjwt_algorithm
- JWT algorithm used for decoding the Bearer token
Returns:
Dict
containing the decoded payload if successful or an exception
if unsuccessful
decode_bearer_token
Decodes a Bearer Token using the specific JWT key and algorithm.
Arguments:
bearer_token
- Encoded Bearer tokenjwt_key
- Public JWT key for decoding the Bearer tokenjwt_algorithm
- JWT algorithm used for decoding the Bearer token
Returns:
Dict
containing the decoded payload if successful or None
if unsuccessful
OutputChannel Objects
Output channel base class.
Provides sane implementation of the send methods for text only output channels.
name
Every output channel needs a name to identify it.
send_response
Send a message to the client.
send_text_message
Send a message through this channel.
send_image_url
Sends an image. Default will just post the url as a string.
send_attachment
Sends an attachment. Default will just post as a string.
send_text_with_buttons
Sends buttons to the output.
Default implementation will just post the buttons as a string.
send_quick_replies
Sends quick replies to the output.
Default implementation will just send as buttons.
send_elements
Sends elements to the output.
Default implementation will just post the elements as a string.
send_custom_json
Sends json dict to the output channel.
Default implementation will just post the json contents as a string.
CollectingOutputChannel Objects
Output channel that collects send messages in a list
(doesn't send them anywhere, just collects them).
__init__
Initialise list to collect messages.
name
Name of the channel.
send_image_url
Sends an image. Default will just post the url as a string.
send_attachment
Sends an attachment. Default will just post as a string.