helpscout.web_hook package

Module contents

class helpscout.web_hook.HelpScoutWebHook(**kwargs)[source]

Bases: helpscout.models.web_hook.WebHook

This provides the ability to easily create & process web hook events.

Required Properties:

  • events (a list of StringChoice): The events to subscribe to., a list (each item is any of “convo.agent.reply.created” (An agent replied to the conversation.), “convo.assigned” (Conversation was assigned.), “convo.created” (Conversation was created.), “convo.customer.reply.created” (The customer replied to the conversation.), “convo.deleted” (Conversation was deleted.), “convo.merged” (Conversation was merged.), “convo.moved” (Conversation was moved.), “convo.note.created” (A note was added to the conversation.), “convo.status” (Conversation status was updated.), “convo.tags” (Conversation tags were updated.), “customer.created” (A customer was created.), “satisfaction.ratings” (A rating was received.))
  • helpscout (object): The authenticated HelpScout object. Used for create., an instance of object
  • id (Integer): Unique identifier, an integer
  • secret_key (String): A randomly-generated (by you) string of 40 characters or less used to create signatures for each webhook method. Help Scout uses this secret key to generate a signature for each webhook message. When the message is received at your callback URL, you can calculate a signature and compare to the one Help Scout sends. If the signatures match, you know it’s from Help Scout., a unicode string
  • url (String): The callback URL where Help Scout will post your webhook events. This is the script or location where you’ll handle the data received from Help Scout., a unicode string
create()[source]

Create the web hook on HelpScout.

helpscout

The authenticated HelpScout object. Used for create.

receive(event_type, signature, data_str)[source]

Receive a web hook for the event and signature.

Parameters:
  • event_type (str) – Name of the event that was received (from the request X-HelpScout-Event header).
  • signature (str) – The signature that was received, which serves as authentication (from the request X-HelpScout-Signature header).
  • data_str (str) – The raw data that was posted by HelpScout to the web hook. This must be the raw string, because if it is parsed with JSON it will lose its ordering and not pass signature validation.
Raises:

helpscout.exceptions.HelpScoutSecurityException – If an invalid signature is provided, and raise_if_invalid is True.

Returns:

The authenticated web hook

request.

Return type:

helpscout.web_hook.WebHookEvent

validate_signature(signature, data, encoding='utf8')[source]

Validate the signature for the provided data.

Parameters:
  • signature (str or bytes or bytearray) – Signature that was provided for the request.
  • data (str or bytes or bytearray) – Data string to validate against the signature.
  • encoding (str, optional) – If a string was provided for data or signature, this is the character encoding.
Returns:

Whether the signature is valid for the provided data.

Return type:

bool

class helpscout.web_hook.WebHookEvent(**kwargs)[source]

Bases: helpscout.base_model.BaseModel

Required Properties:

  • event_type (StringChoice): The event type that this object represents., any of “convo.agent.reply.created” (An agent replied to the conversation.), “convo.assigned” (Conversation was assigned.), “convo.created” (Conversation was created.), “convo.customer.reply.created” (The customer replied to the conversation.), “convo.deleted” (Conversation was deleted.), “convo.merged” (Conversation was merged.), “convo.moved” (Conversation was moved.), “convo.note.created” (A note was added to the conversation.), “convo.status” (Conversation status was updated.), “convo.tags” (Conversation tags were updated.), “customer.created” (A customer was created.), “satisfaction.ratings” (A rating was received.)
  • id (Integer): Unique identifier, an integer
  • record (BaseModel): The parsed data record that was received in the request., an instance of BaseModel
event_type

The event type that this object represents.

record

The parsed data record that was received in the request.